From 18b2d420b092d71313f0c05210c3038ff32483e7 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sun, 6 May 2012 02:21:31 -0400 Subject: added documentation and did some slight restructuring. it's party time. --- nexgb/xgbgen/protocol.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 nexgb/xgbgen/protocol.go (limited to 'nexgb/xgbgen/protocol.go') diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go new file mode 100644 index 0000000..505b400 --- /dev/null +++ b/nexgb/xgbgen/protocol.go @@ -0,0 +1,41 @@ +package main + +import ( + "strings" +) + +// Protocol is a type that encapsulates all information about one +// particular XML file. It also contains links to other protocol types +// if this protocol imports other other extensions. The import relationship +// is recursive. +type Protocol struct { + Name string + ExtXName string + ExtName string + MajorVersion string + MinorVersion string + + Imports []*Protocol + Types []Type + Requests []*Request +} + +// Initialize traverses all structures, looks for 'Translation' type, +// and looks up the real type in the namespace. It also sets the source +// name for all relevant fields/structures. +// This is necessary because we don't traverse the XML in order initially. +func (p *Protocol) Initialize() { + for _, typ := range p.Types { + typ.Initialize(p) + } + for _, req := range p.Requests { + req.Initialize(p) + } +} + +// isExt returns true if this protocol is an extension. +// i.e., it's name isn't "xproto". +func (p *Protocol) isExt() bool { + return strings.ToLower(p.Name) == "xproto" +} + -- cgit v1.2.3-70-g09d2 From 6d545e723a7e972998a0e77adcf2219a31a9b800 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sun, 6 May 2012 17:48:40 -0400 Subject: add more extension cruft. make extension checking more uniform. --- nexgb/xgbgen/context.go | 38 ++++++++++++++++++++++++++++++++++++++ nexgb/xgbgen/go_error.go | 2 +- nexgb/xgbgen/go_event.go | 14 ++++++++++++-- nexgb/xgbgen/go_request_reply.go | 8 ++++---- nexgb/xgbgen/protocol.go | 2 +- nexgb/xgbgen/request_reply.go | 4 ++-- nexgb/xgbgen/translation.go | 2 +- 7 files changed, 59 insertions(+), 11 deletions(-) (limited to 'nexgb/xgbgen/protocol.go') diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index d433531..35dd37e 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -5,6 +5,7 @@ import ( "encoding/xml" "fmt" "log" + "strings" "time" ) @@ -70,6 +71,43 @@ func (c *Context) Morph(xmlBytes []byte) { 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()", + len(xname), xname) + c.Putln("switch {") + c.Putln("case err != nil:") + c.Putln("return err") + c.Putln("case !reply.Present:") + c.Putln("return newError(\"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("}") + c.Putln("c.extLock.Unlock()") + c.Putln("") + c.Putln("return nil") + c.Putln("}") + c.Putln("") + + // Make sure newExtEventFuncs["EXT_NAME"] map is initialized. + c.Putln("func init() {") + c.Putln("newExtEventFuncs[\"%s\"] = make(map[int]newEventFun)", xname) + c.Putln("}") + c.Putln("") + } + // Now write Go source code for _, typ := range c.protocol.Types { typ.Define(c) diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 152db8b..0222289 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -64,7 +64,7 @@ func (e *Error) ImplementsError(c *Context) { c.Putln("}") c.Putln("") c.Putln("func (err %s) BadId() Id {", e.ErrType()) - if c.protocol.Name == "xproto" { + if !c.protocol.isExt() { c.Putln("return Id(err.BadValue)") } else { c.Putln("return 0") diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index 9bc6dfe..ce54e19 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -47,7 +47,12 @@ func (e *Event) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + if c.protocol.isExt() { + c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s", + c.protocol.ExtXName, e.Number, e.EvType()) + } else { + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + } c.Putln("}") c.Putln("") } @@ -130,7 +135,12 @@ func (e *EventCopy) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + if c.protocol.isExt() { + c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s", + c.protocol.ExtXName, e.Number, e.EvType()) + } else { + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + } c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index e64e2a2..451667f 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -118,7 +118,7 @@ func (r *Request) WriteRequest(c *Context) { c.Putln("b := 0") c.Putln("buf := make([]byte, size)") c.Putln("") - if strings.ToLower(c.protocol.Name) != "xproto" { + if c.protocol.isExt() { c.Putln("buf[b] = c.extensions[\"%s\"]", strings.ToUpper(c.protocol.ExtXName)) c.Putln("b += 1") @@ -128,17 +128,17 @@ func (r *Request) WriteRequest(c *Context) { c.Putln("b += 1") c.Putln("") if len(r.Fields) == 0 { - if strings.ToLower(c.protocol.Name) == "xproto" { + if !c.protocol.isExt() { c.Putln("b += 1 // padding") } writeSize() - } else if strings.ToLower(c.protocol.Name) != "xproto" { + } else if c.protocol.isExt() { writeSize() } for i, field := range r.Fields { field.Write(c, "") c.Putln("") - if i == 0 && strings.ToLower(c.protocol.Name) == "xproto" { + if i == 0 && !c.protocol.isExt() { writeSize() } } diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index 505b400..e01bc17 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -36,6 +36,6 @@ func (p *Protocol) Initialize() { // isExt returns true if this protocol is an extension. // i.e., it's name isn't "xproto". func (p *Protocol) isExt() bool { - return strings.ToLower(p.Name) == "xproto" + return strings.ToLower(p.Name) != "xproto" } diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index 7cd2859..c7a4cf8 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -22,7 +22,7 @@ type Request struct { // It also initializes the reply if one exists, and all fields in this request. func (r *Request) Initialize(p *Protocol) { r.srcName = SrcName(p, r.xmlName) - if p.Name != "xproto" { + if p.isExt() { r.srcName = strings.Title(strings.ToLower(p.Name)) + r.srcName } @@ -93,7 +93,7 @@ func (r *Request) Size(c *Context) Size { // request. In an extension request, this byte is always occupied // by the opcode of the request (while the first byte is always occupied // by the opcode of the extension). - if c.protocol.Name == "xproto" { + if !c.protocol.isExt() { size = size.Add(newFixedSize(3)) } else { size = size.Add(newFixedSize(4)) diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 90cd0f3..592c152 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -410,7 +410,7 @@ func TypeSrcName(p *Protocol, typ Type) string { // Since there is no namespace, we need to look for a namespace // in the current context. niceType := splitAndTitle(t) - if p.Name != "xproto" { + if p.isExt() { for _, typ2 := range p.Types { if t == typ2.XmlName() { return strings.Title(p.Name) + niceType -- cgit v1.2.3-70-g09d2 From dc48249e1acea54b391f53b95f16e515dead7c97 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Mon, 7 May 2012 04:09:19 -0400 Subject: lots of docs and examples --- nexgb/Makefile | 6 ++ nexgb/doc.go | 152 +++++++++++++++++++++++++++++++ nexgb/examples/atom.go | 27 ------ nexgb/examples/create-window/main.go | 98 ++++++++++++++++++++ nexgb/examples/doc.go | 21 +++++ nexgb/examples/get-active-window/main.go | 57 ++++++++++++ nexgb/examples/property.go | 41 --------- nexgb/examples/randr.go | 48 ---------- nexgb/examples/randr/main.go | 84 +++++++++++++++++ nexgb/examples/seq-nowrap.go | 29 ------ nexgb/examples/seq-wrap.go | 24 ----- nexgb/examples/window.go | 61 ------------- nexgb/examples/xinerama.go | 29 ------ nexgb/examples/xinerama/main.go | 39 ++++++++ nexgb/xgb.go | 6 -- nexgb/xgb_test.go | 6 +- nexgb/xgbgen/context.go | 2 +- nexgb/xgbgen/field.go | 4 +- nexgb/xgbgen/go_error.go | 2 +- nexgb/xgbgen/go_event.go | 5 +- nexgb/xgbgen/go_list.go | 1 - nexgb/xgbgen/go_request_reply.go | 18 ++-- nexgb/xgbgen/go_union.go | 1 - nexgb/xgbgen/protocol.go | 1 - nexgb/xgbgen/request_reply.go | 4 +- nexgb/xgbgen/translation.go | 2 +- nexgb/xgbgen/xml.go | 32 +++---- 27 files changed, 495 insertions(+), 305 deletions(-) create mode 100644 nexgb/doc.go delete mode 100644 nexgb/examples/atom.go create mode 100644 nexgb/examples/create-window/main.go create mode 100644 nexgb/examples/doc.go create mode 100644 nexgb/examples/get-active-window/main.go delete mode 100644 nexgb/examples/property.go delete mode 100644 nexgb/examples/randr.go create mode 100644 nexgb/examples/randr/main.go delete mode 100644 nexgb/examples/seq-nowrap.go delete mode 100644 nexgb/examples/seq-wrap.go delete mode 100644 nexgb/examples/window.go delete mode 100644 nexgb/examples/xinerama.go create mode 100644 nexgb/examples/xinerama/main.go (limited to 'nexgb/xgbgen/protocol.go') diff --git a/nexgb/Makefile b/nexgb/Makefile index c70b01c..7ba1cb4 100644 --- a/nexgb/Makefile +++ b/nexgb/Makefile @@ -1,5 +1,6 @@ # This Makefile is used by the developer. It is not needed in any way to build # a checkout of the XGB repository. +# It will be useful, however, if you are hacking at the code generator. XPROTO=/usr/share/xcb @@ -20,3 +21,8 @@ test: bench: 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 + diff --git a/nexgb/doc.go b/nexgb/doc.go new file mode 100644 index 0000000..b6c956f --- /dev/null +++ b/nexgb/doc.go @@ -0,0 +1,152 @@ +/* +Package XGB provides the X Go Binding, which is a low-level API to communicate +with the core X protocol and many of the X extensions. + +It is *very* closely modeled on XCB, so that experience with XCB (or xpyb) is +easily translatable to XGB. That is, it uses the same cookie/reply model +and is thread safe. There are otherwise no major differences (in the API). + +Most uses of XGB typically fall under the realm of window manager and GUI kit +development, but other applications (like pagers, panels, tilers, etc.) may +also require XGB. Moreover, it is a near certainty that if you need to work +with X, xgbutil will be of great use to you as well: +https://github.com/BurntSushi/xgbutil + +Example + +This is an extremely terse example that demonstrates how to connect to X, +create a window, listen to StructureNotify events and Key{Press,Release} +events, map the window, and print out all events received. An example with +accompanying documentation can be found in examples/create-window. + + package main + + import ( + "fmt" + "github.com/BurntSushi/xgb" + ) + + func main() { + X, err := xgb.NewConn() + if err != nil { + fmt.Println(err) + return + } + + wid, _ := X.NewId() + X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, + 0, 0, 500, 500, 0, + xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, + xgb.CwBackPixel | xgb.CwEventMask, + []uint32{ // values must be in the order defined by the protocol + 0xffffffff, + xgb.EventMaskStructureNotify | + xgb.EventMaskKeyPress | + xgb.EventMaskKeyRelease}) + + X.MapWindow(wid) + for { + ev, xerr := X.WaitForEvent() + if ev == nil && xerr == nil { + fmt.Println("Both event and error are nil. Exiting...") + return + } + + if ev != nil { + fmt.Printf("Event: %s\n", ev) + } + if xerr != nil { + fmt.Printf("Error: %s\n", xerr) + } + } + } + +Xinerama Example + +This is another small example that shows how to query Xinerama for geometry +information of each active head. Accompanying documentation for this example +can be found in examples/xinerama. + + package main + + import ( + "fmt" + "log" + "github.com/BurntSushi/xgb" + ) + + func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + // 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() + if err != nil { + log.Fatal(err) + } + + reply, err := X.XineramaQueryScreens().Reply() + if err != nil { + log.Fatal(err) + } + + fmt.Printf("Number of heads: %d\n", reply.Number) + for i, screen := range reply.ScreenInfo { + fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n", + i, screen.XOrg, screen.YOrg, screen.Width, screen.Height) + } + } + +Parallelism + +XGB can benefit greatly from parallelism due to its concurrent design. For +evidence of this claim, please see the benchmarks in xgb_test.go. + +Tests + +xgb_test.go contains a number of contrived tests that stress particular corners +of XGB that I presume could be problem areas. Namely: requests with no replies, +requests with replies, checked errors, unchecked errors, sequence number +wrapping, cookie buffer flushing (i.e., forcing a round trip every N requests +made that don't have a reply), getting/setting properties and creating a window +and listening to StructureNotify events. + +Code Generator + +Both XCB and xpyb use the same Python module (xcbgen) for a code generator. XGB +(before this fork) used the same code generator as well, but in my attempt to +add support for more extensions, I found the code generator extremely difficult +to work with. Therefore, I re-wrote the code generator in Go. It can be found +in its own sub-package, xgbgen, of xgb. My design of xgbgen includes a rough +consideration that it could be used for other languages. + +What works + +I am reasonably confident that the core X protocol is in full working form. I've +also tested the Xinerama and RandR extensions sparingly. Many of the other +existing extensions have Go source generated (and are compilable) and are +included in this package, but I am currently unsure of their status. They +*should* work. + +What does not work + +XKB is the only extension that intentionally does not work, although I suspect +that GLX also does not work (however, there is Go source code for GLX that +compiles, unlike XKB). I don't currently have any intention of getting XKB +working, due to its complexity and my current mental incapacity to test it. + +There are so many functions + +Indeed. Everything below this initial overview is useful insomuch as your +browser's "Find" feature is useful. The following list of types and functions +should act as a reference to the Go representation of a request, type or reply +of something you *already know about*. To search the following list in hopes +of attaining understanding is a quest in folly. For understanding, please see +the X Protocol Reference Manual: http://goo.gl/aMd2e + +*/ +package xgb diff --git a/nexgb/examples/atom.go b/nexgb/examples/atom.go deleted file mode 100644 index 2cb7132..0000000 --- a/nexgb/examples/atom.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - // "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func init() { - log.SetFlags(0) -} - -func main() { - X, err := xgb.NewConn() - if err != nil { - log.Fatal(err) - } - - aname := "_NET_ACTIVE_WINDOW" - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - log.Fatal(err) - } - log.Printf("%d", atom.Atom) -} - diff --git a/nexgb/examples/create-window/main.go b/nexgb/examples/create-window/main.go new file mode 100644 index 0000000..6996f37 --- /dev/null +++ b/nexgb/examples/create-window/main.go @@ -0,0 +1,98 @@ +// Example create-window shows how to create a window, map it, resize it, +// and listen to structure and key events (i.e., when the window is resized +// by the window manager, or when key presses/releases are made when the +// window has focus). The events are printed to stdout. +package main + +import ( + "fmt" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + fmt.Println(err) + return + } + + // 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() + + // CreateWindow takes a boatload of parameters. + X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, + 0, 0, 500, 500, 0, + xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, + 0, []uint32{}) + + // This call to ChangeWindowAttributes could be factored out and + // included with the above CreateWindow call, but it is left here for + // instructive purposes. It tells X to send us events when the 'structure' + // of the window is changed (i.e., when it is resized, mapped, unmapped, + // 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, + []uint32{ // values must be in the order defined by the protocol + 0xffffffff, + xgb.EventMaskStructureNotify | + xgb.EventMaskKeyPress | + xgb.EventMaskKeyRelease}) + + // MapWindow makes the window we've created appear on the screen. + // We demonstrated the use of a 'checked' request here. + // A checked request is a fancy way of saying, "do error handling + // synchronously." Namely, if there is a problem with the MapWindow request, + // we'll get the error *here*. If we were to do a normal unchecked + // request (like the above CreateWindow and ChangeWindowAttributes + // requests), then we would only see the error arrive in the main event + // loop. + // + // Typically, checked requests are useful when you need to make sure they + // succeed. Since they are synchronous, they incur a round trip cost before + // the program can continue, but this is only going to be noticeable if + // you're issuing tons of requests in succession. + // + // Note that requests without replies are by default unchecked while + // requests *with* replies are checked by default. + err = X.MapWindowChecked(wid).Check() + if err != nil { + fmt.Printf("Checked Error for mapping window %d: %s\n", wid, err) + } else { + fmt.Printf("Map window %d successful!\n", wid) + } + + // This is an example of an invalid MapWindow request and what an error + // looks like. + err = X.MapWindowChecked(0).Check() + if err != nil { + fmt.Printf("Checked Error for mapping window 0x1: %s\n", err) + } else { // neva + fmt.Printf("Map window 0x1 successful!\n") + } + + // Start the main event loop. + for { + // WaitForEvent either returns an event or an error and never both. + // If both are nil, then something went wrong and the loop should be + // halted. + // + // An error can only be seen here as a response to an unchecked + // request. + ev, xerr := X.WaitForEvent() + if ev == nil && xerr == nil { + fmt.Println("Both event and error are nil. Exiting...") + return + } + + if ev != nil { + fmt.Printf("Event: %s\n", ev) + } + if xerr != nil { + fmt.Printf("Error: %s\n", xerr) + } + } +} diff --git a/nexgb/examples/doc.go b/nexgb/examples/doc.go new file mode 100644 index 0000000..80ea5b7 --- /dev/null +++ b/nexgb/examples/doc.go @@ -0,0 +1,21 @@ +/* +Package examples contains a few different use cases of XGB, like creating +a window, reading properties, and querying for information about multiple +heads using the Xinerama or RandR extensions. + +If you're looking to get started quickly, I recommend checking out the +create-window example first. It is the most documented and probably covers +some of the more common bare bones cases of creating windows and responding +to events. + +If you're looking to query information about your window manager, +get-active-window is a start. However, to do anything extensive requires +a lot of boiler plate. To that end, I'd recommend use of my higher level +library, xgbutil: https://github.com/BurntSushi/xgbutil + +There are also examples of using the Xinerama and RandR extensions, if you're +interested in querying information about your active heads. In RandR's case, +you can also reconfigure your heads, but the example doesn't cover that. + +*/ +package documentation diff --git a/nexgb/examples/get-active-window/main.go b/nexgb/examples/get-active-window/main.go new file mode 100644 index 0000000..e90563c --- /dev/null +++ b/nexgb/examples/get-active-window/main.go @@ -0,0 +1,57 @@ +// Example get-active-window reads the _NET_ACTIVE_WINDOW property of the root +// window and uses the result (a window id) to get the name of the window. +package main + +import ( + "fmt" + "log" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + // Get the window id of the root window. + root := X.DefaultScreen().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() + 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() + if err != nil { + log.Fatal(err) + } + + // Get the actual value of _NET_ACTIVE_WINDOW. + // Note that 'reply.Value' is just a slice of bytes, so we use an + // 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() + if err != nil { + log.Fatal(err) + } + windowId := xgb.Id(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() + if err != nil { + log.Fatal(err) + } + fmt.Printf("Active window name: %s\n", string(reply.Value)) +} diff --git a/nexgb/examples/property.go b/nexgb/examples/property.go deleted file mode 100644 index 45144c7..0000000 --- a/nexgb/examples/property.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "log" - - "github.com/BurntSushi/xgb" -) - -func init() { - log.SetFlags(0) -} - -func get32(buf []byte) uint32 { - v := uint32(buf[0]) - v |= uint32(buf[1]) << 8 - v |= uint32(buf[2]) << 16 - v |= uint32(buf[3]) << 24 - return v -} - -func main() { - X, err := xgb.NewConn() - if err != nil { - log.Fatal(err) - } - - root := X.DefaultScreen().Root - - aname := "_NET_ACTIVE_WINDOW" - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - log.Fatal(err) - } - - reply, err := X.GetProperty(false, root, atom.Atom, - xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply() - if err != nil { - log.Fatal(err) - } - log.Printf("%X", get32(reply.Value)) -} diff --git a/nexgb/examples/randr.go b/nexgb/examples/randr.go deleted file mode 100644 index 064856d..0000000 --- a/nexgb/examples/randr.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - err := X.RegisterExtension("randr") - if err != nil { - log.Fatal(err) - } - - resources, err := X.RandrGetScreenResources(X.DefaultScreen().Root).Reply() - if err != nil { - log.Fatal(err) - } - - for _, output := range resources.Outputs { - info, err := X.RandrGetOutputInfo(output, 0).Reply() - if err != nil { - log.Fatal(err) - } - - bestMode := info.Modes[0] - for _, mode := range resources.Modes { - if mode.Id == uint32(bestMode) { - fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) - } - } - } - - fmt.Println("\n") - - for _, crtc := range resources.Crtcs { - info, err := X.RandrGetCrtcInfo(crtc, 0).Reply() - if err != nil { - log.Fatal(err) - } - fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n", - info.X, info.Y, info.Width, info.Height) - } -} - diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go new file mode 100644 index 0000000..5c56609 --- /dev/null +++ b/nexgb/examples/randr/main.go @@ -0,0 +1,84 @@ +// Example randr uses the randr protocol to get information about the active +// heads. It also listens for events that are sent when the head configuration +// changes. Since it listens to events, you'll have to manually kill this +// process when you're done (i.e., ctrl+c.) +// +// While this program is running, if you use 'xrandr' to reconfigure your +// heads, you should see event information dumped to standard out. +// +// For more information, please see the RandR protocol spec: +// http://www.x.org/releases/X11R7.6/doc/randrproto/randrproto.txt +package main + +import ( + "fmt" + "log" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, _ := xgb.NewConn() + + // Every extension must be initialized before it can be used. + err := X.RandrInit() + if err != nil { + log.Fatal(err) + } + + // 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() + 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() + if err != nil { + log.Fatal(err) + } + + bestMode := info.Modes[0] + for _, mode := range resources.Modes { + if mode.Id == uint32(bestMode) { + fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) + } + } + } + + fmt.Println("\n") + + // Iterate through all of the crtcs and show some of their info. + for _, crtc := range resources.Crtcs { + info, err := X.RandrGetCrtcInfo(crtc, 0).Reply() + if err != nil { + log.Fatal(err) + } + fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n", + info.X, info.Y, info.Width, info.Height) + } + + // 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() + if err != nil { + log.Fatal(err) + } + + // Listen to events and just dump them to standard out. + // A more involved approach will have to read the 'U' field of + // RandrNotifyEvent, which is a union (really a struct) of type + // RanrNotifyDataUnion. + for { + ev, err := X.WaitForEvent() + if err != nil { + log.Fatal(err) + } + fmt.Println(ev) + } +} diff --git a/nexgb/examples/seq-nowrap.go b/nexgb/examples/seq-nowrap.go deleted file mode 100644 index 994a07b..0000000 --- a/nexgb/examples/seq-nowrap.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - for i := 1; i <= 1<<16 + 10; i++ { - X.NoOperation() - // fmt.Printf("%d. No-Op\n", i) - } - - aname := "_NET_ACTIVE_WINDOW" - - for i := 1; i <= 10; i++ { - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - fmt.Println(err) - } else { - fmt.Printf("%d. Sequence: %d, Atom: %d\n", - i, atom.Sequence, atom.Atom) - } - } -} - diff --git a/nexgb/examples/seq-wrap.go b/nexgb/examples/seq-wrap.go deleted file mode 100644 index b5bc834..0000000 --- a/nexgb/examples/seq-wrap.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - aname := "_NET_ACTIVE_WINDOW" - - for i := 1; i <= 1<<16 + 10; i++ { - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - fmt.Println(err) - } else { - fmt.Printf("%d. Sequence: %d, Atom: %d\n", - i, atom.Sequence, atom.Atom) - } - } -} - diff --git a/nexgb/examples/window.go b/nexgb/examples/window.go deleted file mode 100644 index 68fe27b..0000000 --- a/nexgb/examples/window.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, err := xgb.NewConn() - if err != nil { - log.Fatal(err) - } - - wid, _ := X.NewId() - X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, - 0, 0, 500, 500, 0, - xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, - 0, []uint32{}) - X.ChangeWindowAttributes(wid, xgb.CwEventMask | xgb.CwBackPixel, - []uint32{0xffffffff, xgb.EventMaskKeyPress | xgb.EventMaskKeyRelease}) - - err = X.MapWindowChecked(wid).Check() - if err != nil { - fmt.Printf("Checked Error for mapping window %d: %s\n", wid, err) - } else { - fmt.Printf("Map window %d successful!\n", wid) - } - - err = X.MapWindowChecked(0x1).Check() - if err != nil { - fmt.Printf("Checked Error for mapping window 0x1: %s\n", err) - } else { - fmt.Printf("Map window 0x1 successful!\n") - } - - for { - ev, xerr := X.WaitForEvent() - if ev == nil && xerr == nil { - log.Fatal("Both event and error are nil. Exiting...") - } - - if ev != nil { - fmt.Printf("Event: %s\n", ev) - } - if xerr != nil { - fmt.Printf("Error: %s\n", xerr) - } - - if xerr == nil { - geom, err := X.GetGeometry(0x1).Reply() - if err != nil { - fmt.Printf("Geom Error: %#v\n", err) - } else { - fmt.Printf("Geometry: %#v\n", geom) - } - } - } -} - diff --git a/nexgb/examples/xinerama.go b/nexgb/examples/xinerama.go deleted file mode 100644 index 7fe9984..0000000 --- a/nexgb/examples/xinerama.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - err := X.RegisterExtension("xinerama") - if err != nil { - log.Fatal(err) - } - - reply, err := X.XineramaQueryScreens().Reply() - if err != nil { - log.Fatal(err) - } - - fmt.Printf("Xinerama number: %d\n", reply.Number) - for i, screen := range reply.ScreenInfo { - fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n", - i, screen.XOrg, screen.YOrg, screen.Width, screen.Height) - } -} - diff --git a/nexgb/examples/xinerama/main.go b/nexgb/examples/xinerama/main.go new file mode 100644 index 0000000..ec7f46a --- /dev/null +++ b/nexgb/examples/xinerama/main.go @@ -0,0 +1,39 @@ +// Example xinerama shows how to query the geometry of all active heads. +package main + +import ( + "fmt" + "log" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + // 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() + if err != nil { + log.Fatal(err) + } + + // Issue a request to get the screen information. + reply, err := X.XineramaQueryScreens().Reply() + if err != nil { + log.Fatal(err) + } + + // reply.Number is the number of active heads, while reply.ScreenInfo + // is a slice of XineramaScreenInfo containing the rectangle geometry + // of each head. + fmt.Printf("Number of heads: %d\n", reply.Number) + for i, screen := range reply.ScreenInfo { + fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n", + i, screen.XOrg, screen.YOrg, screen.Width, screen.Height) + } +} diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 581b8fa..c9a265f 100644 --- a/nexgb/xgb.go +++ b/nexgb/xgb.go @@ -1,9 +1,3 @@ -// Copyright 2009 The XGB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// The XGB package implements the X11 core protocol. -// It is based on XCB: http://xcb.freedesktop.org/ package xgb import ( diff --git a/nexgb/xgb_test.go b/nexgb/xgb_test.go index 9665164..b70ff5e 100644 --- a/nexgb/xgb_test.go +++ b/nexgb/xgb_test.go @@ -45,8 +45,8 @@ func init() { // Tests /******************************************************************************/ -// TestSynchronousError purposefully causes a BadLength error in an -// InternAtom request, and checks it synchronously. +// 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 if err == nil { @@ -205,7 +205,7 @@ func TestWindowEvents(t *testing.T) { // BenchmarkInternAtomsGood shows how many requests with replies // *should* be sent and gathered from the server. Namely, send as many // requests as you can at once, then go back and gather up all the replies. -// More importantly, this approach can exploit parallelism better when +// More importantly, this approach can exploit parallelism when // GOMAXPROCS > 1. // Run with `go test -run 'nomatch' -bench '.*' -cpu 1,2,6` if you have // multiple cores to see the improvement that parallelism brings. diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index 35dd37e..f1762d3 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -86,7 +86,7 @@ func (c *Context) Morph(xmlBytes []byte) { c.Putln("case err != nil:") c.Putln("return err") c.Putln("case !reply.Present:") - c.Putln("return newError(\"No extension named %s could be found on " + + c.Putln("return newError(\"No extension named %s could be found on "+ "on the server.\")", xname) c.Putln("}") c.Putln("") diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 4452408..7c83f1a 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -220,7 +220,7 @@ func (f *ExprField) Initialize(p *Protocol) { // integers. The mask specifies which kinds of values are in the list. // (i.e., See ConfigureWindow, CreateWindow, ChangeWindowAttributes, etc.) type ValueField struct { - Parent interface{} + Parent interface{} MaskType Type MaskName string ListName string @@ -247,7 +247,7 @@ func (f *ValueField) Size() Size { listSize := newExpressionSize(&Function{ Name: "pad", Expr: &BinaryOp{ - Op: "*", + Op: "*", Expr1: &Value{v: 4}, Expr2: &PopCount{ Expr: &Function{ diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 0222289..9e01042 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -133,7 +133,7 @@ func (e *ErrorCopy) ImplementsError(c *Context) { 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, " + + c.Putln("fieldVals = append(fieldVals, "+ "sprintf(\"Sequence: %s\", err.Sequence))", "%d") for _, field := range fields { switch field.(type) { diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index ce54e19..f55e26f 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -165,7 +165,7 @@ func (e *EventCopy) Write(c *Context) { 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, " + + c.Putln("fieldVals = append(fieldVals, "+ "sprintf(\"Sequence: %s\", v.Sequence))", "%d") } for _, field := range fields { @@ -177,7 +177,8 @@ func EventFieldString(c *Context, fields []Field, evName string) { case *Base: case *Resource: case *TypeDef: - default: continue + default: + continue } switch field.SrcType() { diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index 41cfb76..ad859bb 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -107,4 +107,3 @@ func (f *ListField) Write(c *Context, prefix string) { f.XmlName(), f.Type) } } - diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index 451667f..a9e624d 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -71,14 +71,14 @@ 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("if err != nil {") - c.Putln("return nil, err") - c.Putln("}") - c.Putln("if buf == nil {") - c.Putln("return nil, nil") - c.Putln("}") - c.Putln("return %s(buf), nil", r.ReplyName()) + c.Putln("buf, err := cook.reply()") + c.Putln("if err != nil {") + c.Putln("return nil, err") + c.Putln("}") + c.Putln("if buf == nil {") + c.Putln("return nil, nil") + c.Putln("}") + c.Putln("return %s(buf), nil", r.ReplyName()) c.Putln("}") c.Putln("") @@ -107,7 +107,7 @@ func (r *Request) ReadReply(c *Context) { func (r *Request) WriteRequest(c *Context) { writeSize := func() { - c.Putln("Put16(buf[b:], uint16(size / 4)) "+ + c.Putln("Put16(buf[b:], uint16(size / 4)) " + "// write request size in 4-byte units") c.Putln("b += 2") c.Putln("") diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 9f339af..73e85f7 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -139,4 +139,3 @@ func (u *Union) WriteListSize(c *Context) { c.Putln("}") c.Putln("") } - diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index e01bc17..83dde14 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -38,4 +38,3 @@ func (p *Protocol) Initialize() { func (p *Protocol) isExt() bool { return strings.ToLower(p.Name) != "xproto" } - diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index c7a4cf8..4daa4ac 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -13,9 +13,9 @@ type Request struct { srcName string // The Go name of this request. xmlName string // The XML name of this request. Opcode int - Combine bool // Not currently used. + Combine bool // Not currently used. Fields []Field // All fields in the request. - Reply *Reply // A reply, if one exists for this request. + Reply *Reply // A reply, if one exists for this request. } // Initialize creates the proper Go source name for this request. diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 592c152..e4d81bc 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -339,7 +339,7 @@ func (x *XMLField) Translate(parent interface{}) Field { } case "valueparam": return &ValueField{ - Parent: parent, + Parent: parent, MaskType: newTranslation(x.ValueMaskType), MaskName: x.ValueMaskName, ListName: x.ValueListName, diff --git a/nexgb/xgbgen/xml.go b/nexgb/xgbgen/xml.go index df21433..440d0a8 100644 --- a/nexgb/xgbgen/xml.go +++ b/nexgb/xgbgen/xml.go @@ -17,11 +17,11 @@ type XML struct { // Types for all top-level elements. // First are the simple ones. - Imports XMLImports `xml:"import"` - Enums []*XMLEnum `xml:"enum"` - Xids []*XMLXid `xml:"xidtype"` - XidUnions []*XMLXid `xml:"xidunion"` - TypeDefs []*XMLTypeDef `xml:"typedef"` + Imports XMLImports `xml:"import"` + Enums []*XMLEnum `xml:"enum"` + Xids []*XMLXid `xml:"xidtype"` + XidUnions []*XMLXid `xml:"xidunion"` + TypeDefs []*XMLTypeDef `xml:"typedef"` EventCopies []*XMLEventCopy `xml:"eventcopy"` ErrorCopies []*XMLErrorCopy `xml:"errorcopy"` @@ -93,21 +93,21 @@ type XMLErrorCopy struct { } type XMLStruct struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Fields []*XMLField `xml:",any"` } type XMLUnion struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Fields []*XMLField `xml:",any"` } type XMLRequest struct { - Name string `xml:"name,attr"` - Opcode int `xml:"opcode,attr"` - Combine bool `xml:"combine-adjacent,attr"` + Name string `xml:"name,attr"` + Opcode int `xml:"opcode,attr"` + Combine bool `xml:"combine-adjacent,attr"` Fields []*XMLField `xml:",any"` - Reply *XMLReply `xml:"reply"` + Reply *XMLReply `xml:"reply"` } type XMLReply struct { @@ -115,15 +115,15 @@ type XMLReply struct { } type XMLEvent struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` - NoSequence bool `xml:"no-sequence-number,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` + NoSequence bool `xml:"no-sequence-number,attr"` Fields []*XMLField `xml:",any"` } type XMLError struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` Fields []*XMLField `xml:",any"` } -- cgit v1.2.3-70-g09d2 From 0c50dc6241fa21712e041cfa2bfb9db4ccaef10a Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 17:01:42 -0400 Subject: a huge commit. splitting extensions into their own sub-packages. --- nexgb/Makefile | 25 +- nexgb/auto_bigreq.go | 138 - nexgb/auto_composite.go | 581 -- nexgb/auto_damage.go | 513 - nexgb/auto_dpms.go | 600 -- nexgb/auto_dri2.go | 1560 ---- nexgb/auto_ge.go | 151 - nexgb/auto_glx.go | 9430 ------------------- nexgb/auto_randr.go | 4038 -------- nexgb/auto_record.go | 1095 --- nexgb/auto_render.go | 3556 ------- nexgb/auto_res.go | 528 -- nexgb/auto_screensaver.go | 627 -- nexgb/auto_shape.go | 897 -- nexgb/auto_shm.go | 678 -- nexgb/auto_sync.go | 1949 ---- nexgb/auto_xc_misc.go | 326 - nexgb/auto_xevie.go | 539 -- nexgb/auto_xf86dri.go | 1151 --- nexgb/auto_xf86vidmode.go | 2398 ----- nexgb/auto_xfixes.go | 2173 ----- nexgb/auto_xinerama.go | 655 -- nexgb/auto_xinput.go | 7297 --------------- nexgb/auto_xprint.go | 2210 ----- nexgb/auto_xproto.go | 14490 ----------------------------- nexgb/auto_xselinux.go | 1965 ---- nexgb/auto_xtest.go | 361 - nexgb/auto_xv.go | 2780 ------ nexgb/auto_xvmc.go | 929 -- nexgb/bigreq/bigreq.go | 140 + nexgb/composite/composite.go | 575 ++ nexgb/conn.go | 17 +- nexgb/cookie.go | 36 +- nexgb/damage/damage.go | 511 + nexgb/doc.go | 23 +- nexgb/dpms/dpms.go | 590 ++ nexgb/dri2/dri2.go | 1522 +++ nexgb/examples/create-window/main.go | 33 +- nexgb/examples/get-active-window/main.go | 20 +- nexgb/examples/randr/main.go | 23 +- nexgb/examples/xinerama/main.go | 5 +- nexgb/ge/ge.go | 153 + nexgb/glx/glx.go | 9168 ++++++++++++++++++ nexgb/randr/randr.go | 3964 ++++++++ nexgb/record/record.go | 1089 +++ nexgb/render/render.go | 3542 +++++++ nexgb/res/res.go | 514 + nexgb/screensaver/screensaver.go | 621 ++ nexgb/shape/shape.go | 883 ++ nexgb/shm/shm.go | 672 ++ nexgb/sync.go | 29 + nexgb/sync/sync.go | 1927 ++++ nexgb/xcmisc/xcmisc.go | 320 + nexgb/xevie/xevie.go | 525 ++ nexgb/xf86dri/xf86dri.go | 1121 +++ nexgb/xf86vidmode/xf86vidmode.go | 2360 +++++ nexgb/xfixes/xfixes.go | 2155 +++++ nexgb/xgb.go | 89 +- nexgb/xgb_help.go | 16 +- nexgb/xgb_test.go | 376 - nexgb/xgbgen/context.go | 76 +- nexgb/xgbgen/expression.go | 4 +- nexgb/xgbgen/field.go | 2 +- nexgb/xgbgen/go.go | 10 +- nexgb/xgbgen/go_error.go | 23 +- nexgb/xgbgen/go_event.go | 27 +- nexgb/xgbgen/go_list.go | 22 +- nexgb/xgbgen/go_request_reply.go | 53 +- nexgb/xgbgen/go_single_field.go | 42 +- nexgb/xgbgen/go_struct.go | 10 +- nexgb/xgbgen/go_union.go | 14 +- nexgb/xgbgen/protocol.go | 24 + nexgb/xgbgen/request_reply.go | 3 +- nexgb/xgbgen/translation.go | 36 +- nexgb/xinerama/xinerama.go | 633 ++ nexgb/xinput/xinput.go | 7219 ++++++++++++++ nexgb/xprint/xprint.go | 2164 +++++ nexgb/xproto/xproto.go | 14347 ++++++++++++++++++++++++++++ nexgb/xproto/xproto_test.go | 365 + nexgb/xselinux/xselinux.go | 1903 ++++ nexgb/xtest/xtest.go | 355 + nexgb/xv/xv.go | 2746 ++++++ nexgb/xvmc/xvmc.go | 908 ++ 83 files changed, 63387 insertions(+), 64258 deletions(-) delete mode 100644 nexgb/auto_bigreq.go delete mode 100644 nexgb/auto_composite.go delete mode 100644 nexgb/auto_damage.go delete mode 100644 nexgb/auto_dpms.go delete mode 100644 nexgb/auto_dri2.go delete mode 100644 nexgb/auto_ge.go delete mode 100644 nexgb/auto_glx.go delete mode 100644 nexgb/auto_randr.go delete mode 100644 nexgb/auto_record.go delete mode 100644 nexgb/auto_render.go delete mode 100644 nexgb/auto_res.go delete mode 100644 nexgb/auto_screensaver.go delete mode 100644 nexgb/auto_shape.go delete mode 100644 nexgb/auto_shm.go delete mode 100644 nexgb/auto_sync.go delete mode 100644 nexgb/auto_xc_misc.go delete mode 100644 nexgb/auto_xevie.go delete mode 100644 nexgb/auto_xf86dri.go delete mode 100644 nexgb/auto_xf86vidmode.go delete mode 100644 nexgb/auto_xfixes.go delete mode 100644 nexgb/auto_xinerama.go delete mode 100644 nexgb/auto_xinput.go delete mode 100644 nexgb/auto_xprint.go delete mode 100644 nexgb/auto_xproto.go delete mode 100644 nexgb/auto_xselinux.go delete mode 100644 nexgb/auto_xtest.go delete mode 100644 nexgb/auto_xv.go delete mode 100644 nexgb/auto_xvmc.go create mode 100644 nexgb/bigreq/bigreq.go create mode 100644 nexgb/composite/composite.go create mode 100644 nexgb/damage/damage.go create mode 100644 nexgb/dpms/dpms.go create mode 100644 nexgb/dri2/dri2.go create mode 100644 nexgb/ge/ge.go create mode 100644 nexgb/glx/glx.go create mode 100644 nexgb/randr/randr.go create mode 100644 nexgb/record/record.go create mode 100644 nexgb/render/render.go create mode 100644 nexgb/res/res.go create mode 100644 nexgb/screensaver/screensaver.go create mode 100644 nexgb/shape/shape.go create mode 100644 nexgb/shm/shm.go create mode 100644 nexgb/sync.go create mode 100644 nexgb/sync/sync.go create mode 100644 nexgb/xcmisc/xcmisc.go create mode 100644 nexgb/xevie/xevie.go create mode 100644 nexgb/xf86dri/xf86dri.go create mode 100644 nexgb/xf86vidmode/xf86vidmode.go create mode 100644 nexgb/xfixes/xfixes.go delete mode 100644 nexgb/xgb_test.go create mode 100644 nexgb/xinerama/xinerama.go create mode 100644 nexgb/xinput/xinput.go create mode 100644 nexgb/xprint/xprint.go create mode 100644 nexgb/xproto/xproto.go create mode 100644 nexgb/xproto/xproto_test.go create mode 100644 nexgb/xselinux/xselinux.go create mode 100644 nexgb/xtest/xtest.go create mode 100644 nexgb/xv/xv.go create mode 100644 nexgb/xvmc/xvmc.go (limited to 'nexgb/xgbgen/protocol.go') diff --git a/nexgb/Makefile b/nexgb/Makefile index 56738f4..7fa8b9b 100644 --- a/nexgb/Makefile +++ b/nexgb/Makefile @@ -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 diff --git a/nexgb/auto_bigreq.go b/nexgb/auto_bigreq.go deleted file mode 100644 index e8bbaef..0000000 --- a/nexgb/auto_bigreq.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_composite.go b/nexgb/auto_composite.go deleted file mode 100644 index 836436f..0000000 --- a/nexgb/auto_composite.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_damage.go b/nexgb/auto_damage.go deleted file mode 100644 index 97c76b4..0000000 --- a/nexgb/auto_damage.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_dpms.go b/nexgb/auto_dpms.go deleted file mode 100644 index 8ceab58..0000000 --- a/nexgb/auto_dpms.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_dri2.go b/nexgb/auto_dri2.go deleted file mode 100644 index 09baef5..0000000 --- a/nexgb/auto_dri2.go +++ /dev/null @@ -1,1560 +0,0 @@ -package xgb - -/* - This file was generated by dri2.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" - -// Dri2Init must be called before using the DRI2 extension. -func (c *Conn) Dri2Init() error { - reply, err := c.QueryExtension(4, "DRI2").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named DRI2 could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["DRI2"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["DRI2"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["DRI2"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["DRI2"] = make(map[int]newEventFun) - newExtErrorFuncs["DRI2"] = 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 ( - Dri2AttachmentBufferFrontLeft = 0 - Dri2AttachmentBufferBackLeft = 1 - Dri2AttachmentBufferFrontRight = 2 - Dri2AttachmentBufferBackRight = 3 - Dri2AttachmentBufferDepth = 4 - Dri2AttachmentBufferStencil = 5 - Dri2AttachmentBufferAccum = 6 - Dri2AttachmentBufferFakeFrontLeft = 7 - Dri2AttachmentBufferFakeFrontRight = 8 - Dri2AttachmentBufferDepthStencil = 9 - Dri2AttachmentBufferHiz = 10 -) - -const ( - Dri2DriverTypeDri = 0 - Dri2DriverTypeVdpau = 1 -) - -const ( - Dri2EventTypeExchangeComplete = 1 - Dri2EventTypeBlitComplete = 2 - Dri2EventTypeFlipComplete = 3 -) - -// 'Dri2DRI2Buffer' struct definition -// Size: 20 -type Dri2DRI2Buffer struct { - Attachment uint32 - Name uint32 - Pitch uint32 - Cpp uint32 - Flags uint32 -} - -// Struct read Dri2DRI2Buffer -func ReadDri2DRI2Buffer(buf []byte, v *Dri2DRI2Buffer) int { - b := 0 - - v.Attachment = Get32(buf[b:]) - b += 4 - - v.Name = Get32(buf[b:]) - b += 4 - - v.Pitch = Get32(buf[b:]) - b += 4 - - v.Cpp = Get32(buf[b:]) - b += 4 - - v.Flags = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Dri2DRI2Buffer -func ReadDri2DRI2BufferList(buf []byte, dest []Dri2DRI2Buffer) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Dri2DRI2Buffer{} - b += ReadDri2DRI2Buffer(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Dri2DRI2Buffer -func (v Dri2DRI2Buffer) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - Put32(buf[b:], v.Attachment) - b += 4 - - Put32(buf[b:], v.Name) - b += 4 - - Put32(buf[b:], v.Pitch) - b += 4 - - Put32(buf[b:], v.Cpp) - b += 4 - - Put32(buf[b:], v.Flags) - b += 4 - - return buf -} - -// Write struct list Dri2DRI2Buffer -func Dri2DRI2BufferListBytes(buf []byte, list []Dri2DRI2Buffer) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Dri2AttachFormat' struct definition -// Size: 8 -type Dri2AttachFormat struct { - Attachment uint32 - Format uint32 -} - -// Struct read Dri2AttachFormat -func ReadDri2AttachFormat(buf []byte, v *Dri2AttachFormat) int { - b := 0 - - v.Attachment = Get32(buf[b:]) - b += 4 - - v.Format = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Dri2AttachFormat -func ReadDri2AttachFormatList(buf []byte, dest []Dri2AttachFormat) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Dri2AttachFormat{} - b += ReadDri2AttachFormat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Dri2AttachFormat -func (v Dri2AttachFormat) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], v.Attachment) - b += 4 - - Put32(buf[b:], v.Format) - b += 4 - - return buf -} - -// Write struct list Dri2AttachFormat -func Dri2AttachFormatListBytes(buf []byte, list []Dri2AttachFormat) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Event definition Dri2BufferSwapComplete (0) -// Size: 32 - -const Dri2BufferSwapComplete = 0 - -type Dri2BufferSwapCompleteEvent struct { - Sequence uint16 - // padding: 1 bytes - EventType uint16 - // padding: 2 bytes - Drawable Drawable - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - Sbc uint32 -} - -// Event read Dri2BufferSwapComplete -func NewDri2BufferSwapCompleteEvent(buf []byte) Event { - v := Dri2BufferSwapCompleteEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.EventType = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.Sbc = Get32(buf[b:]) - b += 4 - - return v -} - -// Event write Dri2BufferSwapComplete -func (v Dri2BufferSwapCompleteEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put16(buf[b:], v.EventType) - b += 2 - - b += 2 // padding - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], v.UstHi) - b += 4 - - Put32(buf[b:], v.UstLo) - b += 4 - - Put32(buf[b:], v.MscHi) - b += 4 - - Put32(buf[b:], v.MscLo) - b += 4 - - Put32(buf[b:], v.Sbc) - b += 4 - - return buf -} - -func (v Dri2BufferSwapCompleteEvent) ImplementsEvent() {} - -func (v Dri2BufferSwapCompleteEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v Dri2BufferSwapCompleteEvent) String() string { - fieldVals := make([]string, 0, 9) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("EventType: %d", v.EventType)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("UstHi: %d", v.UstHi)) - fieldVals = append(fieldVals, sprintf("UstLo: %d", v.UstLo)) - fieldVals = append(fieldVals, sprintf("MscHi: %d", v.MscHi)) - fieldVals = append(fieldVals, sprintf("MscLo: %d", v.MscLo)) - fieldVals = append(fieldVals, sprintf("Sbc: %d", v.Sbc)) - return "Dri2BufferSwapComplete {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["DRI2"][0] = NewDri2BufferSwapCompleteEvent -} - -// Event definition Dri2InvalidateBuffers (1) -// Size: 32 - -const Dri2InvalidateBuffers = 1 - -type Dri2InvalidateBuffersEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable -} - -// Event read Dri2InvalidateBuffers -func NewDri2InvalidateBuffersEvent(buf []byte) Event { - v := Dri2InvalidateBuffersEvent{} - 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 - - return v -} - -// Event write Dri2InvalidateBuffers -func (v Dri2InvalidateBuffersEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - return buf -} - -func (v Dri2InvalidateBuffersEvent) ImplementsEvent() {} - -func (v Dri2InvalidateBuffersEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v Dri2InvalidateBuffersEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - return "Dri2InvalidateBuffers {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["DRI2"][1] = NewDri2InvalidateBuffersEvent -} - -// Request Dri2QueryVersion -// size: 12 -type Dri2QueryVersionCookie struct { - *cookie -} - -func (c *Conn) Dri2QueryVersion(MajorVersion uint32, MinorVersion uint32) Dri2QueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2QueryVersionRequest(MajorVersion, MinorVersion), cookie) - return Dri2QueryVersionCookie{cookie} -} - -func (c *Conn) Dri2QueryVersionUnchecked(MajorVersion uint32, MinorVersion uint32) Dri2QueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2QueryVersionRequest(MajorVersion, MinorVersion), cookie) - return Dri2QueryVersionCookie{cookie} -} - -// Request reply for Dri2QueryVersion -// size: 16 -type Dri2QueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 -} - -// Waits and reads reply data from request Dri2QueryVersion -func (cook Dri2QueryVersionCookie) Reply() (*Dri2QueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2QueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for Dri2QueryVersion -func dri2QueryVersionReply(buf []byte) *Dri2QueryVersionReply { - v := new(Dri2QueryVersionReply) - 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 - - return v -} - -func (cook Dri2QueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2QueryVersion -func (c *Conn) dri2QueryVersionRequest(MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// Request Dri2Connect -// size: 12 -type Dri2ConnectCookie struct { - *cookie -} - -func (c *Conn) Dri2Connect(Window Window, DriverType uint32) Dri2ConnectCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2ConnectRequest(Window, DriverType), cookie) - return Dri2ConnectCookie{cookie} -} - -func (c *Conn) Dri2ConnectUnchecked(Window Window, DriverType uint32) Dri2ConnectCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2ConnectRequest(Window, DriverType), cookie) - return Dri2ConnectCookie{cookie} -} - -// Request reply for Dri2Connect -// size: (((32 + pad((int(DriverNameLength) * 1))) + pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1))) + pad((int(DeviceNameLength) * 1))) -type Dri2ConnectReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DriverNameLength uint32 - DeviceNameLength uint32 - // padding: 16 bytes - DriverName string // size: pad((int(DriverNameLength) * 1)) - AlignmentPad []byte // size: pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1)) - DeviceName string // size: pad((int(DeviceNameLength) * 1)) -} - -// Waits and reads reply data from request Dri2Connect -func (cook Dri2ConnectCookie) Reply() (*Dri2ConnectReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2ConnectReply(buf), nil -} - -// Read reply into structure from buffer for Dri2Connect -func dri2ConnectReply(buf []byte) *Dri2ConnectReply { - v := new(Dri2ConnectReply) - 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.DriverNameLength = Get32(buf[b:]) - b += 4 - - v.DeviceNameLength = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.DriverNameLength) - copy(byteString[:v.DriverNameLength], buf[b:]) - v.DriverName = string(byteString) - b += pad(int(v.DriverNameLength)) - } - - v.AlignmentPad = make([]byte, (((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength))) - copy(v.AlignmentPad[:(((int(v.DriverNameLength)+3)&-4)-int(v.DriverNameLength))], buf[b:]) - b += pad(int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))) - - { - byteString := make([]byte, v.DeviceNameLength) - copy(byteString[:v.DeviceNameLength], buf[b:]) - v.DeviceName = string(byteString) - b += pad(int(v.DeviceNameLength)) - } - - return v -} - -func (cook Dri2ConnectCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2Connect -func (c *Conn) dri2ConnectRequest(Window Window, DriverType uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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:], DriverType) - b += 4 - - return buf -} - -// Request Dri2Authenticate -// size: 12 -type Dri2AuthenticateCookie struct { - *cookie -} - -func (c *Conn) Dri2Authenticate(Window Window, Magic uint32) Dri2AuthenticateCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2AuthenticateRequest(Window, Magic), cookie) - return Dri2AuthenticateCookie{cookie} -} - -func (c *Conn) Dri2AuthenticateUnchecked(Window Window, Magic uint32) Dri2AuthenticateCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2AuthenticateRequest(Window, Magic), cookie) - return Dri2AuthenticateCookie{cookie} -} - -// Request reply for Dri2Authenticate -// size: 12 -type Dri2AuthenticateReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Authenticated uint32 -} - -// Waits and reads reply data from request Dri2Authenticate -func (cook Dri2AuthenticateCookie) Reply() (*Dri2AuthenticateReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2AuthenticateReply(buf), nil -} - -// Read reply into structure from buffer for Dri2Authenticate -func dri2AuthenticateReply(buf []byte) *Dri2AuthenticateReply { - v := new(Dri2AuthenticateReply) - 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.Authenticated = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2AuthenticateCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2Authenticate -func (c *Conn) dri2AuthenticateRequest(Window Window, Magic uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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 - - Put32(buf[b:], Magic) - b += 4 - - return buf -} - -// Request Dri2CreateDrawable -// size: 8 -type Dri2CreateDrawableCookie struct { - *cookie -} - -// Write request to wire for Dri2CreateDrawable -func (c *Conn) Dri2CreateDrawable(Drawable Drawable) Dri2CreateDrawableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dri2CreateDrawableRequest(Drawable), cookie) - return Dri2CreateDrawableCookie{cookie} -} - -func (c *Conn) Dri2CreateDrawableChecked(Drawable Drawable) Dri2CreateDrawableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dri2CreateDrawableRequest(Drawable), cookie) - return Dri2CreateDrawableCookie{cookie} -} - -func (cook Dri2CreateDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2CreateDrawable -func (c *Conn) dri2CreateDrawableRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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 - - return buf -} - -// Request Dri2DestroyDrawable -// size: 8 -type Dri2DestroyDrawableCookie struct { - *cookie -} - -// Write request to wire for Dri2DestroyDrawable -func (c *Conn) Dri2DestroyDrawable(Drawable Drawable) Dri2DestroyDrawableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dri2DestroyDrawableRequest(Drawable), cookie) - return Dri2DestroyDrawableCookie{cookie} -} - -func (c *Conn) Dri2DestroyDrawableChecked(Drawable Drawable) Dri2DestroyDrawableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dri2DestroyDrawableRequest(Drawable), cookie) - return Dri2DestroyDrawableCookie{cookie} -} - -func (cook Dri2DestroyDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2DestroyDrawable -func (c *Conn) dri2DestroyDrawableRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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 Dri2GetBuffers -// size: pad((12 + pad((len(Attachments) * 4)))) -type Dri2GetBuffersCookie struct { - *cookie -} - -func (c *Conn) Dri2GetBuffers(Drawable Drawable, Count uint32, Attachments []uint32) Dri2GetBuffersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2GetBuffersRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersCookie{cookie} -} - -func (c *Conn) Dri2GetBuffersUnchecked(Drawable Drawable, Count uint32, Attachments []uint32) Dri2GetBuffersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2GetBuffersRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersCookie{cookie} -} - -// Request reply for Dri2GetBuffers -// size: (32 + pad((int(Count) * 20))) -type Dri2GetBuffersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint32 - Height uint32 - Count uint32 - // padding: 12 bytes - Buffers []Dri2DRI2Buffer // size: pad((int(Count) * 20)) -} - -// Waits and reads reply data from request Dri2GetBuffers -func (cook Dri2GetBuffersCookie) Reply() (*Dri2GetBuffersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2GetBuffersReply(buf), nil -} - -// Read reply into structure from buffer for Dri2GetBuffers -func dri2GetBuffersReply(buf []byte) *Dri2GetBuffersReply { - v := new(Dri2GetBuffersReply) - 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.Count = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Buffers = make([]Dri2DRI2Buffer, v.Count) - b += ReadDri2DRI2BufferList(buf[b:], v.Buffers) - - return v -} - -func (cook Dri2GetBuffersCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2GetBuffers -func (c *Conn) dri2GetBuffersRequest(Drawable Drawable, Count uint32, Attachments []uint32) []byte { - size := pad((12 + pad((len(Attachments) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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(Drawable)) - b += 4 - - Put32(buf[b:], Count) - b += 4 - - for i := 0; i < int(len(Attachments)); i++ { - Put32(buf[b:], Attachments[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request Dri2CopyRegion -// size: 20 -type Dri2CopyRegionCookie struct { - *cookie -} - -func (c *Conn) Dri2CopyRegion(Drawable Drawable, Region uint32, Dest uint32, Src uint32) Dri2CopyRegionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2CopyRegionRequest(Drawable, Region, Dest, Src), cookie) - return Dri2CopyRegionCookie{cookie} -} - -func (c *Conn) Dri2CopyRegionUnchecked(Drawable Drawable, Region uint32, Dest uint32, Src uint32) Dri2CopyRegionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2CopyRegionRequest(Drawable, Region, Dest, Src), cookie) - return Dri2CopyRegionCookie{cookie} -} - -// Request reply for Dri2CopyRegion -// size: 8 -type Dri2CopyRegionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes -} - -// Waits and reads reply data from request Dri2CopyRegion -func (cook Dri2CopyRegionCookie) Reply() (*Dri2CopyRegionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2CopyRegionReply(buf), nil -} - -// Read reply into structure from buffer for Dri2CopyRegion -func dri2CopyRegionReply(buf []byte) *Dri2CopyRegionReply { - v := new(Dri2CopyRegionReply) - 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 - - return v -} - -func (cook Dri2CopyRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2CopyRegion -func (c *Conn) dri2CopyRegionRequest(Drawable Drawable, Region uint32, Dest uint32, Src uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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(Drawable)) - b += 4 - - Put32(buf[b:], Region) - b += 4 - - Put32(buf[b:], Dest) - b += 4 - - Put32(buf[b:], Src) - b += 4 - - return buf -} - -// Request Dri2GetBuffersWithFormat -// size: pad((12 + pad((len(Attachments) * 8)))) -type Dri2GetBuffersWithFormatCookie struct { - *cookie -} - -func (c *Conn) Dri2GetBuffersWithFormat(Drawable Drawable, Count uint32, Attachments []Dri2AttachFormat) Dri2GetBuffersWithFormatCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2GetBuffersWithFormatRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersWithFormatCookie{cookie} -} - -func (c *Conn) Dri2GetBuffersWithFormatUnchecked(Drawable Drawable, Count uint32, Attachments []Dri2AttachFormat) Dri2GetBuffersWithFormatCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2GetBuffersWithFormatRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersWithFormatCookie{cookie} -} - -// Request reply for Dri2GetBuffersWithFormat -// size: (32 + pad((int(Count) * 20))) -type Dri2GetBuffersWithFormatReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint32 - Height uint32 - Count uint32 - // padding: 12 bytes - Buffers []Dri2DRI2Buffer // size: pad((int(Count) * 20)) -} - -// Waits and reads reply data from request Dri2GetBuffersWithFormat -func (cook Dri2GetBuffersWithFormatCookie) Reply() (*Dri2GetBuffersWithFormatReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2GetBuffersWithFormatReply(buf), nil -} - -// Read reply into structure from buffer for Dri2GetBuffersWithFormat -func dri2GetBuffersWithFormatReply(buf []byte) *Dri2GetBuffersWithFormatReply { - v := new(Dri2GetBuffersWithFormatReply) - 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.Count = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Buffers = make([]Dri2DRI2Buffer, v.Count) - b += ReadDri2DRI2BufferList(buf[b:], v.Buffers) - - return v -} - -func (cook Dri2GetBuffersWithFormatCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2GetBuffersWithFormat -func (c *Conn) dri2GetBuffersWithFormatRequest(Drawable Drawable, Count uint32, Attachments []Dri2AttachFormat) []byte { - size := pad((12 + pad((len(Attachments) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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(Drawable)) - b += 4 - - Put32(buf[b:], Count) - b += 4 - - b += Dri2AttachFormatListBytes(buf[b:], Attachments) - - return buf -} - -// Request Dri2SwapBuffers -// size: 32 -type Dri2SwapBuffersCookie struct { - *cookie -} - -func (c *Conn) Dri2SwapBuffers(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2SwapBuffersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2SwapBuffersRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2SwapBuffersCookie{cookie} -} - -func (c *Conn) Dri2SwapBuffersUnchecked(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2SwapBuffersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2SwapBuffersRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2SwapBuffersCookie{cookie} -} - -// Request reply for Dri2SwapBuffers -// size: 16 -type Dri2SwapBuffersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - SwapHi uint32 - SwapLo uint32 -} - -// Waits and reads reply data from request Dri2SwapBuffers -func (cook Dri2SwapBuffersCookie) Reply() (*Dri2SwapBuffersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2SwapBuffersReply(buf), nil -} - -// Read reply into structure from buffer for Dri2SwapBuffers -func dri2SwapBuffersReply(buf []byte) *Dri2SwapBuffersReply { - v := new(Dri2SwapBuffersReply) - 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.SwapHi = Get32(buf[b:]) - b += 4 - - v.SwapLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2SwapBuffersCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2SwapBuffers -func (c *Conn) dri2SwapBuffersRequest(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - 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(Drawable)) - b += 4 - - Put32(buf[b:], TargetMscHi) - b += 4 - - Put32(buf[b:], TargetMscLo) - b += 4 - - Put32(buf[b:], DivisorHi) - b += 4 - - Put32(buf[b:], DivisorLo) - b += 4 - - Put32(buf[b:], RemainderHi) - b += 4 - - Put32(buf[b:], RemainderLo) - b += 4 - - return buf -} - -// Request Dri2GetMSC -// size: 8 -type Dri2GetMSCCookie struct { - *cookie -} - -func (c *Conn) Dri2GetMSC(Drawable Drawable) Dri2GetMSCCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2GetMSCRequest(Drawable), cookie) - return Dri2GetMSCCookie{cookie} -} - -func (c *Conn) Dri2GetMSCUnchecked(Drawable Drawable) Dri2GetMSCCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2GetMSCRequest(Drawable), cookie) - return Dri2GetMSCCookie{cookie} -} - -// Request reply for Dri2GetMSC -// size: 32 -type Dri2GetMSCReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 -} - -// Waits and reads reply data from request Dri2GetMSC -func (cook Dri2GetMSCCookie) Reply() (*Dri2GetMSCReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2GetMSCReply(buf), nil -} - -// Read reply into structure from buffer for Dri2GetMSC -func dri2GetMSCReply(buf []byte) *Dri2GetMSCReply { - v := new(Dri2GetMSCReply) - 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.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.SbcHi = Get32(buf[b:]) - b += 4 - - v.SbcLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2GetMSCCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2GetMSC -func (c *Conn) dri2GetMSCRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 9 // 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 Dri2WaitMSC -// size: 32 -type Dri2WaitMSCCookie struct { - *cookie -} - -func (c *Conn) Dri2WaitMSC(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2WaitMSCCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2WaitMSCRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2WaitMSCCookie{cookie} -} - -func (c *Conn) Dri2WaitMSCUnchecked(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2WaitMSCCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2WaitMSCRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2WaitMSCCookie{cookie} -} - -// Request reply for Dri2WaitMSC -// size: 32 -type Dri2WaitMSCReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 -} - -// Waits and reads reply data from request Dri2WaitMSC -func (cook Dri2WaitMSCCookie) Reply() (*Dri2WaitMSCReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2WaitMSCReply(buf), nil -} - -// Read reply into structure from buffer for Dri2WaitMSC -func dri2WaitMSCReply(buf []byte) *Dri2WaitMSCReply { - v := new(Dri2WaitMSCReply) - 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.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.SbcHi = Get32(buf[b:]) - b += 4 - - v.SbcLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2WaitMSCCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2WaitMSC -func (c *Conn) dri2WaitMSCRequest(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 10 // 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:], TargetMscHi) - b += 4 - - Put32(buf[b:], TargetMscLo) - b += 4 - - Put32(buf[b:], DivisorHi) - b += 4 - - Put32(buf[b:], DivisorLo) - b += 4 - - Put32(buf[b:], RemainderHi) - b += 4 - - Put32(buf[b:], RemainderLo) - b += 4 - - return buf -} - -// Request Dri2WaitSBC -// size: 16 -type Dri2WaitSBCCookie struct { - *cookie -} - -func (c *Conn) Dri2WaitSBC(Drawable Drawable, TargetSbcHi uint32, TargetSbcLo uint32) Dri2WaitSBCCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2WaitSBCRequest(Drawable, TargetSbcHi, TargetSbcLo), cookie) - return Dri2WaitSBCCookie{cookie} -} - -func (c *Conn) Dri2WaitSBCUnchecked(Drawable Drawable, TargetSbcHi uint32, TargetSbcLo uint32) Dri2WaitSBCCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2WaitSBCRequest(Drawable, TargetSbcHi, TargetSbcLo), cookie) - return Dri2WaitSBCCookie{cookie} -} - -// Request reply for Dri2WaitSBC -// size: 32 -type Dri2WaitSBCReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 -} - -// Waits and reads reply data from request Dri2WaitSBC -func (cook Dri2WaitSBCCookie) Reply() (*Dri2WaitSBCReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2WaitSBCReply(buf), nil -} - -// Read reply into structure from buffer for Dri2WaitSBC -func dri2WaitSBCReply(buf []byte) *Dri2WaitSBCReply { - v := new(Dri2WaitSBCReply) - 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.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.SbcHi = Get32(buf[b:]) - b += 4 - - v.SbcLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2WaitSBCCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2WaitSBC -func (c *Conn) dri2WaitSBCRequest(Drawable Drawable, TargetSbcHi uint32, TargetSbcLo uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 11 // 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:], TargetSbcHi) - b += 4 - - Put32(buf[b:], TargetSbcLo) - b += 4 - - return buf -} - -// Request Dri2SwapInterval -// size: 12 -type Dri2SwapIntervalCookie struct { - *cookie -} - -// Write request to wire for Dri2SwapInterval -func (c *Conn) Dri2SwapInterval(Drawable Drawable, Interval uint32) Dri2SwapIntervalCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dri2SwapIntervalRequest(Drawable, Interval), cookie) - return Dri2SwapIntervalCookie{cookie} -} - -func (c *Conn) Dri2SwapIntervalChecked(Drawable Drawable, Interval uint32) Dri2SwapIntervalCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dri2SwapIntervalRequest(Drawable, Interval), cookie) - return Dri2SwapIntervalCookie{cookie} -} - -func (cook Dri2SwapIntervalCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2SwapInterval -func (c *Conn) dri2SwapIntervalRequest(Drawable Drawable, Interval uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 12 // 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:], Interval) - b += 4 - - return buf -} diff --git a/nexgb/auto_ge.go b/nexgb/auto_ge.go deleted file mode 100644 index 3d1b00c..0000000 --- a/nexgb/auto_ge.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_glx.go b/nexgb/auto_glx.go deleted file mode 100644 index 0fe0f61..0000000 --- a/nexgb/auto_glx.go +++ /dev/null @@ -1,9430 +0,0 @@ -package xgb - -/* - This file was generated by glx.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" - -// GlxInit must be called before using the GLX extension. -func (c *Conn) GlxInit() error { - reply, err := c.QueryExtension(3, "GLX").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named GLX could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["GLX"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["GLX"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["GLX"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["GLX"] = make(map[int]newEventFun) - newExtErrorFuncs["GLX"] = make(map[int]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 ( - GlxPbcetDamaged = 32791 - GlxPbcetSaved = 32792 -) - -const ( - GlxPbcdtWindow = 32793 - GlxPbcdtPbuffer = 32794 -) - -const ( - GlxGcGlCurrentBit = 1 - GlxGcGlPointBit = 2 - GlxGcGlLineBit = 4 - GlxGcGlPolygonBit = 8 - GlxGcGlPolygonStippleBit = 16 - GlxGcGlPixelModeBit = 32 - GlxGcGlLightingBit = 64 - GlxGcGlFogBit = 128 - GlxGcGlDepthBufferBit = 256 - GlxGcGlAccumBufferBit = 512 - GlxGcGlStencilBufferBit = 1024 - GlxGcGlViewportBit = 2048 - GlxGcGlTransformBit = 4096 - GlxGcGlEnableBit = 8192 - GlxGcGlColorBufferBit = 16384 - GlxGcGlHintBit = 32768 - GlxGcGlEvalBit = 65536 - GlxGcGlListBit = 131072 - GlxGcGlTextureBit = 262144 - GlxGcGlScissorBit = 524288 - GlxGcGlAllAttribBits = 16777215 -) - -const ( - GlxRmGlRender = 7168 - GlxRmGlFeedback = 7169 - GlxRmGlSelect = 7170 -) - -type GlxPixmap uint32 - -func (c *Conn) NewGlxPixmapId() (GlxPixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxPixmap(id), nil -} - -type GlxContext uint32 - -func (c *Conn) NewGlxContextId() (GlxContext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxContext(id), nil -} - -type GlxPbuffer uint32 - -func (c *Conn) NewGlxPbufferId() (GlxPbuffer, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxPbuffer(id), nil -} - -type GlxWindow uint32 - -func (c *Conn) NewGlxWindowId() (GlxWindow, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxWindow(id), nil -} - -type GlxFbconfig uint32 - -func (c *Conn) NewGlxFbconfigId() (GlxFbconfig, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxFbconfig(id), nil -} - -type GlxDrawable uint32 - -func (c *Conn) NewGlxDrawableId() (GlxDrawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxDrawable(id), nil -} - -type GlxFloat32 float64 - -type GlxFloat64 float64 - -type GlxBool32 uint32 - -type GlxContextTag uint32 - -// Event definition GlxPbufferClobber (0) -// Size: 32 - -const GlxPbufferClobber = 0 - -type GlxPbufferClobberEvent struct { - Sequence uint16 - // padding: 1 bytes - EventType uint16 - DrawType uint16 - Drawable GlxDrawable - BMask uint32 - AuxBuffer uint16 - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 4 bytes -} - -// Event read GlxPbufferClobber -func NewGlxPbufferClobberEvent(buf []byte) Event { - v := GlxPbufferClobberEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.EventType = Get16(buf[b:]) - b += 2 - - v.DrawType = Get16(buf[b:]) - b += 2 - - v.Drawable = GlxDrawable(Get32(buf[b:])) - b += 4 - - v.BMask = Get32(buf[b:]) - b += 4 - - v.AuxBuffer = Get16(buf[b:]) - b += 2 - - v.X = Get16(buf[b:]) - b += 2 - - v.Y = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Count = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - return v -} - -// Event write GlxPbufferClobber -func (v GlxPbufferClobberEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put16(buf[b:], v.EventType) - b += 2 - - Put16(buf[b:], v.DrawType) - b += 2 - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], v.BMask) - b += 4 - - Put16(buf[b:], v.AuxBuffer) - b += 2 - - Put16(buf[b:], v.X) - b += 2 - - Put16(buf[b:], v.Y) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Count) - b += 2 - - b += 4 // padding - - return buf -} - -func (v GlxPbufferClobberEvent) ImplementsEvent() {} - -func (v GlxPbufferClobberEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v GlxPbufferClobberEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("EventType: %d", v.EventType)) - fieldVals = append(fieldVals, sprintf("DrawType: %d", v.DrawType)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("BMask: %d", v.BMask)) - fieldVals = append(fieldVals, sprintf("AuxBuffer: %d", v.AuxBuffer)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - return "GlxPbufferClobber {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["GLX"][0] = NewGlxPbufferClobberEvent -} - -// Error definition GlxGeneric (-1) -// Size: 32 - -const BadGlxGeneric = -1 - -type GlxGenericError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 21 bytes -} - -// Error read GlxGeneric -func NewGlxGenericError(buf []byte) Error { - v := GlxGenericError{} - v.NiceName = "GlxGeneric" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadValue = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 21 // padding - - return v -} - -func (err GlxGenericError) ImplementsError() {} - -func (err GlxGenericError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxGenericError) BadId() uint32 { - return 0 -} - -func (err GlxGenericError) 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 "BadGlxGeneric {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][-1] = NewGlxGenericError -} - -// ErrorCopy definition GlxBadContext (0) - -const BadGlxBadContext = 0 - -type GlxBadContextError GlxGenericError - -func NewGlxBadContextError(buf []byte) Error { - v := GlxBadContextError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadContext" - return v -} - -func (err GlxBadContextError) ImplementsError() {} - -func (err GlxBadContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadContextError) BadId() uint32 { - return 0 -} - -func (err GlxBadContextError) 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 "BadGlxBadContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][0] = NewGlxBadContextError -} - -// ErrorCopy definition GlxBadContextState (1) - -const BadGlxBadContextState = 1 - -type GlxBadContextStateError GlxGenericError - -func NewGlxBadContextStateError(buf []byte) Error { - v := GlxBadContextStateError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadContextState" - return v -} - -func (err GlxBadContextStateError) ImplementsError() {} - -func (err GlxBadContextStateError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadContextStateError) BadId() uint32 { - return 0 -} - -func (err GlxBadContextStateError) 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 "BadGlxBadContextState {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][1] = NewGlxBadContextStateError -} - -// ErrorCopy definition GlxBadDrawable (2) - -const BadGlxBadDrawable = 2 - -type GlxBadDrawableError GlxGenericError - -func NewGlxBadDrawableError(buf []byte) Error { - v := GlxBadDrawableError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadDrawable" - return v -} - -func (err GlxBadDrawableError) ImplementsError() {} - -func (err GlxBadDrawableError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadDrawableError) BadId() uint32 { - return 0 -} - -func (err GlxBadDrawableError) 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 "BadGlxBadDrawable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][2] = NewGlxBadDrawableError -} - -// ErrorCopy definition GlxBadPixmap (3) - -const BadGlxBadPixmap = 3 - -type GlxBadPixmapError GlxGenericError - -func NewGlxBadPixmapError(buf []byte) Error { - v := GlxBadPixmapError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadPixmap" - return v -} - -func (err GlxBadPixmapError) ImplementsError() {} - -func (err GlxBadPixmapError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadPixmapError) BadId() uint32 { - return 0 -} - -func (err GlxBadPixmapError) 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 "BadGlxBadPixmap {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][3] = NewGlxBadPixmapError -} - -// ErrorCopy definition GlxBadContextTag (4) - -const BadGlxBadContextTag = 4 - -type GlxBadContextTagError GlxGenericError - -func NewGlxBadContextTagError(buf []byte) Error { - v := GlxBadContextTagError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadContextTag" - return v -} - -func (err GlxBadContextTagError) ImplementsError() {} - -func (err GlxBadContextTagError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadContextTagError) BadId() uint32 { - return 0 -} - -func (err GlxBadContextTagError) 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 "BadGlxBadContextTag {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][4] = NewGlxBadContextTagError -} - -// ErrorCopy definition GlxBadCurrentWindow (5) - -const BadGlxBadCurrentWindow = 5 - -type GlxBadCurrentWindowError GlxGenericError - -func NewGlxBadCurrentWindowError(buf []byte) Error { - v := GlxBadCurrentWindowError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadCurrentWindow" - return v -} - -func (err GlxBadCurrentWindowError) ImplementsError() {} - -func (err GlxBadCurrentWindowError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadCurrentWindowError) BadId() uint32 { - return 0 -} - -func (err GlxBadCurrentWindowError) 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 "BadGlxBadCurrentWindow {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][5] = NewGlxBadCurrentWindowError -} - -// ErrorCopy definition GlxBadRenderRequest (6) - -const BadGlxBadRenderRequest = 6 - -type GlxBadRenderRequestError GlxGenericError - -func NewGlxBadRenderRequestError(buf []byte) Error { - v := GlxBadRenderRequestError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadRenderRequest" - return v -} - -func (err GlxBadRenderRequestError) ImplementsError() {} - -func (err GlxBadRenderRequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadRenderRequestError) BadId() uint32 { - return 0 -} - -func (err GlxBadRenderRequestError) 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 "BadGlxBadRenderRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][6] = NewGlxBadRenderRequestError -} - -// ErrorCopy definition GlxBadLargeRequest (7) - -const BadGlxBadLargeRequest = 7 - -type GlxBadLargeRequestError GlxGenericError - -func NewGlxBadLargeRequestError(buf []byte) Error { - v := GlxBadLargeRequestError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadLargeRequest" - return v -} - -func (err GlxBadLargeRequestError) ImplementsError() {} - -func (err GlxBadLargeRequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadLargeRequestError) BadId() uint32 { - return 0 -} - -func (err GlxBadLargeRequestError) 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 "BadGlxBadLargeRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][7] = NewGlxBadLargeRequestError -} - -// ErrorCopy definition GlxUnsupportedPrivateRequest (8) - -const BadGlxUnsupportedPrivateRequest = 8 - -type GlxUnsupportedPrivateRequestError GlxGenericError - -func NewGlxUnsupportedPrivateRequestError(buf []byte) Error { - v := GlxUnsupportedPrivateRequestError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxUnsupportedPrivateRequest" - return v -} - -func (err GlxUnsupportedPrivateRequestError) ImplementsError() {} - -func (err GlxUnsupportedPrivateRequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxUnsupportedPrivateRequestError) BadId() uint32 { - return 0 -} - -func (err GlxUnsupportedPrivateRequestError) 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 "BadGlxUnsupportedPrivateRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][8] = NewGlxUnsupportedPrivateRequestError -} - -// ErrorCopy definition GlxBadFBConfig (9) - -const BadGlxBadFBConfig = 9 - -type GlxBadFBConfigError GlxGenericError - -func NewGlxBadFBConfigError(buf []byte) Error { - v := GlxBadFBConfigError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadFBConfig" - return v -} - -func (err GlxBadFBConfigError) ImplementsError() {} - -func (err GlxBadFBConfigError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadFBConfigError) BadId() uint32 { - return 0 -} - -func (err GlxBadFBConfigError) 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 "BadGlxBadFBConfig {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][9] = NewGlxBadFBConfigError -} - -// ErrorCopy definition GlxBadPbuffer (10) - -const BadGlxBadPbuffer = 10 - -type GlxBadPbufferError GlxGenericError - -func NewGlxBadPbufferError(buf []byte) Error { - v := GlxBadPbufferError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadPbuffer" - return v -} - -func (err GlxBadPbufferError) ImplementsError() {} - -func (err GlxBadPbufferError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadPbufferError) BadId() uint32 { - return 0 -} - -func (err GlxBadPbufferError) 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 "BadGlxBadPbuffer {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][10] = NewGlxBadPbufferError -} - -// ErrorCopy definition GlxBadCurrentDrawable (11) - -const BadGlxBadCurrentDrawable = 11 - -type GlxBadCurrentDrawableError GlxGenericError - -func NewGlxBadCurrentDrawableError(buf []byte) Error { - v := GlxBadCurrentDrawableError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadCurrentDrawable" - return v -} - -func (err GlxBadCurrentDrawableError) ImplementsError() {} - -func (err GlxBadCurrentDrawableError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadCurrentDrawableError) BadId() uint32 { - return 0 -} - -func (err GlxBadCurrentDrawableError) 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 "BadGlxBadCurrentDrawable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][11] = NewGlxBadCurrentDrawableError -} - -// ErrorCopy definition GlxBadWindow (12) - -const BadGlxBadWindow = 12 - -type GlxBadWindowError GlxGenericError - -func NewGlxBadWindowError(buf []byte) Error { - v := GlxBadWindowError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadWindow" - return v -} - -func (err GlxBadWindowError) ImplementsError() {} - -func (err GlxBadWindowError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadWindowError) BadId() uint32 { - return 0 -} - -func (err GlxBadWindowError) 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 "BadGlxBadWindow {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][12] = NewGlxBadWindowError -} - -// ErrorCopy definition GlxGLXBadProfileARB (13) - -const BadGlxGLXBadProfileARB = 13 - -type GlxGLXBadProfileARBError GlxGenericError - -func NewGlxGLXBadProfileARBError(buf []byte) Error { - v := GlxGLXBadProfileARBError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxGLXBadProfileARB" - return v -} - -func (err GlxGLXBadProfileARBError) ImplementsError() {} - -func (err GlxGLXBadProfileARBError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxGLXBadProfileARBError) BadId() uint32 { - return 0 -} - -func (err GlxGLXBadProfileARBError) 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 "BadGlxGLXBadProfileARB {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][13] = NewGlxGLXBadProfileARBError -} - -// Request GlxRender -// size: pad((8 + pad((len(Data) * 1)))) -type GlxRenderCookie struct { - *cookie -} - -// Write request to wire for GlxRender -func (c *Conn) GlxRender(ContextTag GlxContextTag, Data []byte) GlxRenderCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxRenderRequest(ContextTag, Data), cookie) - return GlxRenderCookie{cookie} -} - -func (c *Conn) GlxRenderChecked(ContextTag GlxContextTag, Data []byte) GlxRenderCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxRenderRequest(ContextTag, Data), cookie) - return GlxRenderCookie{cookie} -} - -func (cook GlxRenderCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxRender -func (c *Conn) glxRenderRequest(ContextTag GlxContextTag, Data []byte) []byte { - size := pad((8 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GlxRenderLarge -// size: pad((16 + pad((int(DataLen) * 1)))) -type GlxRenderLargeCookie struct { - *cookie -} - -// Write request to wire for GlxRenderLarge -func (c *Conn) GlxRenderLarge(ContextTag GlxContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) GlxRenderLargeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxRenderLargeRequest(ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return GlxRenderLargeCookie{cookie} -} - -func (c *Conn) GlxRenderLargeChecked(ContextTag GlxContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) GlxRenderLargeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxRenderLargeRequest(ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return GlxRenderLargeCookie{cookie} -} - -func (cook GlxRenderLargeCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxRenderLarge -func (c *Conn) glxRenderLargeRequest(ContextTag GlxContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { - size := pad((16 + pad((int(DataLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(ContextTag)) - b += 4 - - Put16(buf[b:], RequestNum) - b += 2 - - Put16(buf[b:], RequestTotal) - b += 2 - - Put32(buf[b:], DataLen) - b += 4 - - copy(buf[b:], Data[:DataLen]) - b += pad(int(DataLen)) - - return buf -} - -// Request GlxCreateContext -// size: 24 -type GlxCreateContextCookie struct { - *cookie -} - -// Write request to wire for GlxCreateContext -func (c *Conn) GlxCreateContext(Context GlxContext, Visual Visualid, Screen uint32, ShareList GlxContext, IsDirect bool) GlxCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateContextRequest(Context, Visual, Screen, ShareList, IsDirect), cookie) - return GlxCreateContextCookie{cookie} -} - -func (c *Conn) GlxCreateContextChecked(Context GlxContext, Visual Visualid, Screen uint32, ShareList GlxContext, IsDirect bool) GlxCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateContextRequest(Context, Visual, Screen, ShareList, IsDirect), cookie) - return GlxCreateContextCookie{cookie} -} - -func (cook GlxCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateContext -func (c *Conn) glxCreateContextRequest(Context GlxContext, Visual Visualid, Screen uint32, ShareList GlxContext, IsDirect bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(Context)) - b += 4 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request GlxDestroyContext -// size: 8 -type GlxDestroyContextCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyContext -func (c *Conn) GlxDestroyContext(Context GlxContext) GlxDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyContextRequest(Context), cookie) - return GlxDestroyContextCookie{cookie} -} - -func (c *Conn) GlxDestroyContextChecked(Context GlxContext) GlxDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyContextRequest(Context), cookie) - return GlxDestroyContextCookie{cookie} -} - -func (cook GlxDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyContext -func (c *Conn) glxDestroyContextRequest(Context GlxContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(Context)) - b += 4 - - return buf -} - -// Request GlxMakeCurrent -// size: 16 -type GlxMakeCurrentCookie struct { - *cookie -} - -func (c *Conn) GlxMakeCurrent(Drawable GlxDrawable, Context GlxContext, OldContextTag GlxContextTag) GlxMakeCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxMakeCurrentRequest(Drawable, Context, OldContextTag), cookie) - return GlxMakeCurrentCookie{cookie} -} - -func (c *Conn) GlxMakeCurrentUnchecked(Drawable GlxDrawable, Context GlxContext, OldContextTag GlxContextTag) GlxMakeCurrentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxMakeCurrentRequest(Drawable, Context, OldContextTag), cookie) - return GlxMakeCurrentCookie{cookie} -} - -// Request reply for GlxMakeCurrent -// size: 32 -type GlxMakeCurrentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextTag GlxContextTag - // padding: 20 bytes -} - -// Waits and reads reply data from request GlxMakeCurrent -func (cook GlxMakeCurrentCookie) Reply() (*GlxMakeCurrentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxMakeCurrentReply(buf), nil -} - -// Read reply into structure from buffer for GlxMakeCurrent -func glxMakeCurrentReply(buf []byte) *GlxMakeCurrentReply { - v := new(GlxMakeCurrentReply) - 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.ContextTag = GlxContextTag(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook GlxMakeCurrentCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxMakeCurrent -func (c *Conn) glxMakeCurrentRequest(Drawable GlxDrawable, Context GlxContext, OldContextTag GlxContextTag) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(OldContextTag)) - b += 4 - - return buf -} - -// Request GlxIsDirect -// size: 8 -type GlxIsDirectCookie struct { - *cookie -} - -func (c *Conn) GlxIsDirect(Context GlxContext) GlxIsDirectCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsDirectRequest(Context), cookie) - return GlxIsDirectCookie{cookie} -} - -func (c *Conn) GlxIsDirectUnchecked(Context GlxContext) GlxIsDirectCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsDirectRequest(Context), cookie) - return GlxIsDirectCookie{cookie} -} - -// Request reply for GlxIsDirect -// size: 32 -type GlxIsDirectReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - IsDirect bool - // padding: 23 bytes -} - -// Waits and reads reply data from request GlxIsDirect -func (cook GlxIsDirectCookie) Reply() (*GlxIsDirectReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsDirectReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsDirect -func glxIsDirectReply(buf []byte) *GlxIsDirectReply { - v := new(GlxIsDirectReply) - 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.IsDirect = true - } else { - v.IsDirect = false - } - b += 1 - - b += 23 // padding - - return v -} - -func (cook GlxIsDirectCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsDirect -func (c *Conn) glxIsDirectRequest(Context GlxContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(Context)) - b += 4 - - return buf -} - -// Request GlxQueryVersion -// size: 12 -type GlxQueryVersionCookie struct { - *cookie -} - -func (c *Conn) GlxQueryVersion(MajorVersion uint32, MinorVersion uint32) GlxQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return GlxQueryVersionCookie{cookie} -} - -func (c *Conn) GlxQueryVersionUnchecked(MajorVersion uint32, MinorVersion uint32) GlxQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return GlxQueryVersionCookie{cookie} -} - -// Request reply for GlxQueryVersion -// size: 32 -type GlxQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request GlxQueryVersion -func (cook GlxQueryVersionCookie) Reply() (*GlxQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryVersion -func glxQueryVersionReply(buf []byte) *GlxQueryVersionReply { - v := new(GlxQueryVersionReply) - 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 GlxQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryVersion -func (c *Conn) glxQueryVersionRequest(MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// Request GlxWaitGL -// size: 8 -type GlxWaitGLCookie struct { - *cookie -} - -// Write request to wire for GlxWaitGL -func (c *Conn) GlxWaitGL(ContextTag GlxContextTag) GlxWaitGLCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxWaitGLRequest(ContextTag), cookie) - return GlxWaitGLCookie{cookie} -} - -func (c *Conn) GlxWaitGLChecked(ContextTag GlxContextTag) GlxWaitGLCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxWaitGLRequest(ContextTag), cookie) - return GlxWaitGLCookie{cookie} -} - -func (cook GlxWaitGLCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxWaitGL -func (c *Conn) glxWaitGLRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - 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(ContextTag)) - b += 4 - - return buf -} - -// Request GlxWaitX -// size: 8 -type GlxWaitXCookie struct { - *cookie -} - -// Write request to wire for GlxWaitX -func (c *Conn) GlxWaitX(ContextTag GlxContextTag) GlxWaitXCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxWaitXRequest(ContextTag), cookie) - return GlxWaitXCookie{cookie} -} - -func (c *Conn) GlxWaitXChecked(ContextTag GlxContextTag) GlxWaitXCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxWaitXRequest(ContextTag), cookie) - return GlxWaitXCookie{cookie} -} - -func (cook GlxWaitXCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxWaitX -func (c *Conn) glxWaitXRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxCopyContext -// size: 20 -type GlxCopyContextCookie struct { - *cookie -} - -// Write request to wire for GlxCopyContext -func (c *Conn) GlxCopyContext(Src GlxContext, Dest GlxContext, Mask uint32, SrcContextTag GlxContextTag) GlxCopyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCopyContextRequest(Src, Dest, Mask, SrcContextTag), cookie) - return GlxCopyContextCookie{cookie} -} - -func (c *Conn) GlxCopyContextChecked(Src GlxContext, Dest GlxContext, Mask uint32, SrcContextTag GlxContextTag) GlxCopyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCopyContextRequest(Src, Dest, Mask, SrcContextTag), cookie) - return GlxCopyContextCookie{cookie} -} - -func (cook GlxCopyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCopyContext -func (c *Conn) glxCopyContextRequest(Src GlxContext, Dest GlxContext, Mask uint32, SrcContextTag GlxContextTag) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dest)) - b += 4 - - Put32(buf[b:], Mask) - b += 4 - - Put32(buf[b:], uint32(SrcContextTag)) - b += 4 - - return buf -} - -// Request GlxSwapBuffers -// size: 12 -type GlxSwapBuffersCookie struct { - *cookie -} - -// Write request to wire for GlxSwapBuffers -func (c *Conn) GlxSwapBuffers(ContextTag GlxContextTag, Drawable GlxDrawable) GlxSwapBuffersCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSwapBuffersRequest(ContextTag, Drawable), cookie) - return GlxSwapBuffersCookie{cookie} -} - -func (c *Conn) GlxSwapBuffersChecked(ContextTag GlxContextTag, Drawable GlxDrawable) GlxSwapBuffersCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSwapBuffersRequest(ContextTag, Drawable), cookie) - return GlxSwapBuffersCookie{cookie} -} - -func (cook GlxSwapBuffersCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSwapBuffers -func (c *Conn) glxSwapBuffersRequest(ContextTag GlxContextTag, Drawable GlxDrawable) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request GlxUseXFont -// size: 24 -type GlxUseXFontCookie struct { - *cookie -} - -// Write request to wire for GlxUseXFont -func (c *Conn) GlxUseXFont(ContextTag GlxContextTag, Font Font, First uint32, Count uint32, ListBase uint32) GlxUseXFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxUseXFontRequest(ContextTag, Font, First, Count, ListBase), cookie) - return GlxUseXFontCookie{cookie} -} - -func (c *Conn) GlxUseXFontChecked(ContextTag GlxContextTag, Font Font, First uint32, Count uint32, ListBase uint32) GlxUseXFontCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxUseXFontRequest(ContextTag, Font, First, Count, ListBase), cookie) - return GlxUseXFontCookie{cookie} -} - -func (cook GlxUseXFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxUseXFont -func (c *Conn) glxUseXFontRequest(ContextTag GlxContextTag, Font Font, First uint32, Count uint32, ListBase uint32) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Font)) - b += 4 - - Put32(buf[b:], First) - b += 4 - - Put32(buf[b:], Count) - b += 4 - - Put32(buf[b:], ListBase) - b += 4 - - return buf -} - -// Request GlxCreateGLXPixmap -// size: 20 -type GlxCreateGLXPixmapCookie struct { - *cookie -} - -// Write request to wire for GlxCreateGLXPixmap -func (c *Conn) GlxCreateGLXPixmap(Screen uint32, Visual Visualid, Pixmap Pixmap, GlxPixmap GlxPixmap) GlxCreateGLXPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateGLXPixmapRequest(Screen, Visual, Pixmap, GlxPixmap), cookie) - return GlxCreateGLXPixmapCookie{cookie} -} - -func (c *Conn) GlxCreateGLXPixmapChecked(Screen uint32, Visual Visualid, Pixmap Pixmap, GlxPixmap GlxPixmap) GlxCreateGLXPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateGLXPixmapRequest(Screen, Visual, Pixmap, GlxPixmap), cookie) - return GlxCreateGLXPixmapCookie{cookie} -} - -func (cook GlxCreateGLXPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateGLXPixmap -func (c *Conn) glxCreateGLXPixmapRequest(Screen uint32, Visual Visualid, Pixmap Pixmap, GlxPixmap GlxPixmap) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 13 // 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 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - return buf -} - -// Request GlxGetVisualConfigs -// size: 8 -type GlxGetVisualConfigsCookie struct { - *cookie -} - -func (c *Conn) GlxGetVisualConfigs(Screen uint32) GlxGetVisualConfigsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetVisualConfigsRequest(Screen), cookie) - return GlxGetVisualConfigsCookie{cookie} -} - -func (c *Conn) GlxGetVisualConfigsUnchecked(Screen uint32) GlxGetVisualConfigsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetVisualConfigsRequest(Screen), cookie) - return GlxGetVisualConfigsCookie{cookie} -} - -// Request reply for GlxGetVisualConfigs -// size: (32 + pad((int(Length) * 4))) -type GlxGetVisualConfigsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumVisuals uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGetVisualConfigs -func (cook GlxGetVisualConfigsCookie) Reply() (*GlxGetVisualConfigsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetVisualConfigsReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetVisualConfigs -func glxGetVisualConfigsReply(buf []byte) *GlxGetVisualConfigsReply { - v := new(GlxGetVisualConfigsReply) - 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.NumVisuals = Get32(buf[b:]) - b += 4 - - v.NumProperties = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetVisualConfigsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetVisualConfigs -func (c *Conn) glxGetVisualConfigsRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 14 // 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 GlxDestroyGLXPixmap -// size: 8 -type GlxDestroyGLXPixmapCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyGLXPixmap -func (c *Conn) GlxDestroyGLXPixmap(GlxPixmap GlxPixmap) GlxDestroyGLXPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyGLXPixmapRequest(GlxPixmap), cookie) - return GlxDestroyGLXPixmapCookie{cookie} -} - -func (c *Conn) GlxDestroyGLXPixmapChecked(GlxPixmap GlxPixmap) GlxDestroyGLXPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyGLXPixmapRequest(GlxPixmap), cookie) - return GlxDestroyGLXPixmapCookie{cookie} -} - -func (cook GlxDestroyGLXPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyGLXPixmap -func (c *Conn) glxDestroyGLXPixmapRequest(GlxPixmap GlxPixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - return buf -} - -// Request GlxVendorPrivate -// size: pad((12 + pad((len(Data) * 1)))) -type GlxVendorPrivateCookie struct { - *cookie -} - -// Write request to wire for GlxVendorPrivate -func (c *Conn) GlxVendorPrivate(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxVendorPrivateRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateCookie{cookie} -} - -func (c *Conn) GlxVendorPrivateChecked(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxVendorPrivateRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateCookie{cookie} -} - -func (cook GlxVendorPrivateCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxVendorPrivate -func (c *Conn) glxVendorPrivateRequest(VendorCode uint32, ContextTag GlxContextTag, Data []byte) []byte { - size := pad((12 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], VendorCode) - b += 4 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GlxVendorPrivateWithReply -// size: pad((12 + pad((len(Data) * 1)))) -type GlxVendorPrivateWithReplyCookie struct { - *cookie -} - -func (c *Conn) GlxVendorPrivateWithReply(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateWithReplyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxVendorPrivateWithReplyRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateWithReplyCookie{cookie} -} - -func (c *Conn) GlxVendorPrivateWithReplyUnchecked(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateWithReplyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxVendorPrivateWithReplyRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateWithReplyCookie{cookie} -} - -// Request reply for GlxVendorPrivateWithReply -// size: (36 + pad(((int(Length) * 4) * 1))) -type GlxVendorPrivateWithReplyReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Retval uint32 - Data1 []byte // size: 24 - Data2 []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxVendorPrivateWithReply -func (cook GlxVendorPrivateWithReplyCookie) Reply() (*GlxVendorPrivateWithReplyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxVendorPrivateWithReplyReply(buf), nil -} - -// Read reply into structure from buffer for GlxVendorPrivateWithReply -func glxVendorPrivateWithReplyReply(buf []byte) *GlxVendorPrivateWithReplyReply { - v := new(GlxVendorPrivateWithReplyReply) - 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.Retval = Get32(buf[b:]) - b += 4 - - v.Data1 = make([]byte, 24) - copy(v.Data1[:24], buf[b:]) - b += pad(int(24)) - - v.Data2 = make([]byte, (int(v.Length) * 4)) - copy(v.Data2[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxVendorPrivateWithReplyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxVendorPrivateWithReply -func (c *Conn) glxVendorPrivateWithReplyRequest(VendorCode uint32, ContextTag GlxContextTag, Data []byte) []byte { - size := pad((12 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], VendorCode) - b += 4 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GlxQueryExtensionsString -// size: 8 -type GlxQueryExtensionsStringCookie struct { - *cookie -} - -func (c *Conn) GlxQueryExtensionsString(Screen uint32) GlxQueryExtensionsStringCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryExtensionsStringRequest(Screen), cookie) - return GlxQueryExtensionsStringCookie{cookie} -} - -func (c *Conn) GlxQueryExtensionsStringUnchecked(Screen uint32) GlxQueryExtensionsStringCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryExtensionsStringRequest(Screen), cookie) - return GlxQueryExtensionsStringCookie{cookie} -} - -// Request reply for GlxQueryExtensionsString -// size: 32 -type GlxQueryExtensionsStringReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request GlxQueryExtensionsString -func (cook GlxQueryExtensionsStringCookie) Reply() (*GlxQueryExtensionsStringReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryExtensionsStringReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryExtensionsString -func glxQueryExtensionsStringReply(buf []byte) *GlxQueryExtensionsStringReply { - v := new(GlxQueryExtensionsStringReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook GlxQueryExtensionsStringCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryExtensionsString -func (c *Conn) glxQueryExtensionsStringRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 18 // 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 GlxQueryServerString -// size: 12 -type GlxQueryServerStringCookie struct { - *cookie -} - -func (c *Conn) GlxQueryServerString(Screen uint32, Name uint32) GlxQueryServerStringCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryServerStringRequest(Screen, Name), cookie) - return GlxQueryServerStringCookie{cookie} -} - -func (c *Conn) GlxQueryServerStringUnchecked(Screen uint32, Name uint32) GlxQueryServerStringCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryServerStringRequest(Screen, Name), cookie) - return GlxQueryServerStringCookie{cookie} -} - -// Request reply for GlxQueryServerString -// size: (32 + pad((int(StrLen) * 1))) -type GlxQueryServerStringReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - StrLen uint32 - // padding: 16 bytes - String string // size: pad((int(StrLen) * 1)) -} - -// Waits and reads reply data from request GlxQueryServerString -func (cook GlxQueryServerStringCookie) Reply() (*GlxQueryServerStringReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryServerStringReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryServerString -func glxQueryServerStringReply(buf []byte) *GlxQueryServerStringReply { - v := new(GlxQueryServerStringReply) - 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 += 4 // padding - - v.StrLen = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.StrLen) - copy(byteString[:v.StrLen], buf[b:]) - v.String = string(byteString) - b += pad(int(v.StrLen)) - } - - return v -} - -func (cook GlxQueryServerStringCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryServerString -func (c *Conn) glxQueryServerStringRequest(Screen uint32, Name uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 19 // 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 - - Put32(buf[b:], Name) - b += 4 - - return buf -} - -// Request GlxClientInfo -// size: pad((16 + pad((int(StrLen) * 1)))) -type GlxClientInfoCookie struct { - *cookie -} - -// Write request to wire for GlxClientInfo -func (c *Conn) GlxClientInfo(MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) GlxClientInfoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxClientInfoRequest(MajorVersion, MinorVersion, StrLen, String), cookie) - return GlxClientInfoCookie{cookie} -} - -func (c *Conn) GlxClientInfoChecked(MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) GlxClientInfoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxClientInfoRequest(MajorVersion, MinorVersion, StrLen, String), cookie) - return GlxClientInfoCookie{cookie} -} - -func (cook GlxClientInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxClientInfo -func (c *Conn) glxClientInfoRequest(MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { - size := pad((16 + pad((int(StrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - Put32(buf[b:], StrLen) - b += 4 - - copy(buf[b:], String[:StrLen]) - b += pad(int(StrLen)) - - return buf -} - -// Request GlxGetFBConfigs -// size: 8 -type GlxGetFBConfigsCookie struct { - *cookie -} - -func (c *Conn) GlxGetFBConfigs(Screen uint32) GlxGetFBConfigsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetFBConfigsRequest(Screen), cookie) - return GlxGetFBConfigsCookie{cookie} -} - -func (c *Conn) GlxGetFBConfigsUnchecked(Screen uint32) GlxGetFBConfigsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetFBConfigsRequest(Screen), cookie) - return GlxGetFBConfigsCookie{cookie} -} - -// Request reply for GlxGetFBConfigs -// size: (32 + pad((int(Length) * 4))) -type GlxGetFBConfigsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFbConfigs uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGetFBConfigs -func (cook GlxGetFBConfigsCookie) Reply() (*GlxGetFBConfigsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetFBConfigsReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetFBConfigs -func glxGetFBConfigsReply(buf []byte) *GlxGetFBConfigsReply { - v := new(GlxGetFBConfigsReply) - 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.NumFbConfigs = Get32(buf[b:]) - b += 4 - - v.NumProperties = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetFBConfigsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetFBConfigs -func (c *Conn) glxGetFBConfigsRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 21 // 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 GlxCreatePixmap -// size: pad((24 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreatePixmapCookie struct { - *cookie -} - -// Write request to wire for GlxCreatePixmap -func (c *Conn) GlxCreatePixmap(Screen uint32, Fbconfig GlxFbconfig, Pixmap Pixmap, GlxPixmap GlxPixmap, NumAttribs uint32, Attribs []uint32) GlxCreatePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreatePixmapRequest(Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return GlxCreatePixmapCookie{cookie} -} - -func (c *Conn) GlxCreatePixmapChecked(Screen uint32, Fbconfig GlxFbconfig, Pixmap Pixmap, GlxPixmap GlxPixmap, NumAttribs uint32, Attribs []uint32) GlxCreatePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreatePixmapRequest(Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return GlxCreatePixmapCookie{cookie} -} - -func (cook GlxCreatePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreatePixmap -func (c *Conn) glxCreatePixmapRequest(Screen uint32, Fbconfig GlxFbconfig, Pixmap Pixmap, GlxPixmap GlxPixmap, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((24 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 22 // 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 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDestroyPixmap -// size: 8 -type GlxDestroyPixmapCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyPixmap -func (c *Conn) GlxDestroyPixmap(GlxPixmap GlxPixmap) GlxDestroyPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyPixmapRequest(GlxPixmap), cookie) - return GlxDestroyPixmapCookie{cookie} -} - -func (c *Conn) GlxDestroyPixmapChecked(GlxPixmap GlxPixmap) GlxDestroyPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyPixmapRequest(GlxPixmap), cookie) - return GlxDestroyPixmapCookie{cookie} -} - -func (cook GlxDestroyPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyPixmap -func (c *Conn) glxDestroyPixmapRequest(GlxPixmap GlxPixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - return buf -} - -// Request GlxCreateNewContext -// size: 28 -type GlxCreateNewContextCookie struct { - *cookie -} - -// Write request to wire for GlxCreateNewContext -func (c *Conn) GlxCreateNewContext(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, RenderType uint32, ShareList GlxContext, IsDirect bool) GlxCreateNewContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateNewContextRequest(Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) - return GlxCreateNewContextCookie{cookie} -} - -func (c *Conn) GlxCreateNewContextChecked(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, RenderType uint32, ShareList GlxContext, IsDirect bool) GlxCreateNewContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateNewContextRequest(Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) - return GlxCreateNewContextCookie{cookie} -} - -func (cook GlxCreateNewContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateNewContext -func (c *Conn) glxCreateNewContextRequest(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, RenderType uint32, ShareList GlxContext, IsDirect bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], RenderType) - b += 4 - - Put32(buf[b:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request GlxQueryContext -// size: 8 -type GlxQueryContextCookie struct { - *cookie -} - -func (c *Conn) GlxQueryContext(Context GlxContext) GlxQueryContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryContextRequest(Context), cookie) - return GlxQueryContextCookie{cookie} -} - -func (c *Conn) GlxQueryContextUnchecked(Context GlxContext) GlxQueryContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryContextRequest(Context), cookie) - return GlxQueryContextCookie{cookie} -} - -// Request reply for GlxQueryContext -// size: (32 + pad(((int(NumAttribs) * 2) * 4))) -type GlxQueryContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: pad(((int(NumAttribs) * 2) * 4)) -} - -// Waits and reads reply data from request GlxQueryContext -func (cook GlxQueryContextCookie) Reply() (*GlxQueryContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryContextReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryContext -func glxQueryContextReply(buf []byte) *GlxQueryContextReply { - v := new(GlxQueryContextReply) - 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.NumAttribs = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxQueryContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryContext -func (c *Conn) glxQueryContextRequest(Context GlxContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request GlxMakeContextCurrent -// size: 20 -type GlxMakeContextCurrentCookie struct { - *cookie -} - -func (c *Conn) GlxMakeContextCurrent(OldContextTag GlxContextTag, Drawable GlxDrawable, ReadDrawable GlxDrawable, Context GlxContext) GlxMakeContextCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxMakeContextCurrentRequest(OldContextTag, Drawable, ReadDrawable, Context), cookie) - return GlxMakeContextCurrentCookie{cookie} -} - -func (c *Conn) GlxMakeContextCurrentUnchecked(OldContextTag GlxContextTag, Drawable GlxDrawable, ReadDrawable GlxDrawable, Context GlxContext) GlxMakeContextCurrentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxMakeContextCurrentRequest(OldContextTag, Drawable, ReadDrawable, Context), cookie) - return GlxMakeContextCurrentCookie{cookie} -} - -// Request reply for GlxMakeContextCurrent -// size: 32 -type GlxMakeContextCurrentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextTag GlxContextTag - // padding: 20 bytes -} - -// Waits and reads reply data from request GlxMakeContextCurrent -func (cook GlxMakeContextCurrentCookie) Reply() (*GlxMakeContextCurrentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxMakeContextCurrentReply(buf), nil -} - -// Read reply into structure from buffer for GlxMakeContextCurrent -func glxMakeContextCurrentReply(buf []byte) *GlxMakeContextCurrentReply { - v := new(GlxMakeContextCurrentReply) - 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.ContextTag = GlxContextTag(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook GlxMakeContextCurrentCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxMakeContextCurrent -func (c *Conn) glxMakeContextCurrentRequest(OldContextTag GlxContextTag, Drawable GlxDrawable, ReadDrawable GlxDrawable, Context GlxContext) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(OldContextTag)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(ReadDrawable)) - b += 4 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request GlxCreatePbuffer -// size: pad((20 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreatePbufferCookie struct { - *cookie -} - -// Write request to wire for GlxCreatePbuffer -func (c *Conn) GlxCreatePbuffer(Screen uint32, Fbconfig GlxFbconfig, Pbuffer GlxPbuffer, NumAttribs uint32, Attribs []uint32) GlxCreatePbufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreatePbufferRequest(Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return GlxCreatePbufferCookie{cookie} -} - -func (c *Conn) GlxCreatePbufferChecked(Screen uint32, Fbconfig GlxFbconfig, Pbuffer GlxPbuffer, NumAttribs uint32, Attribs []uint32) GlxCreatePbufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreatePbufferRequest(Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return GlxCreatePbufferCookie{cookie} -} - -func (cook GlxCreatePbufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreatePbuffer -func (c *Conn) glxCreatePbufferRequest(Screen uint32, Fbconfig GlxFbconfig, Pbuffer GlxPbuffer, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((20 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 27 // 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 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], uint32(Pbuffer)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDestroyPbuffer -// size: 8 -type GlxDestroyPbufferCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyPbuffer -func (c *Conn) GlxDestroyPbuffer(Pbuffer GlxPbuffer) GlxDestroyPbufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyPbufferRequest(Pbuffer), cookie) - return GlxDestroyPbufferCookie{cookie} -} - -func (c *Conn) GlxDestroyPbufferChecked(Pbuffer GlxPbuffer) GlxDestroyPbufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyPbufferRequest(Pbuffer), cookie) - return GlxDestroyPbufferCookie{cookie} -} - -func (cook GlxDestroyPbufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyPbuffer -func (c *Conn) glxDestroyPbufferRequest(Pbuffer GlxPbuffer) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pbuffer)) - b += 4 - - return buf -} - -// Request GlxGetDrawableAttributes -// size: 8 -type GlxGetDrawableAttributesCookie struct { - *cookie -} - -func (c *Conn) GlxGetDrawableAttributes(Drawable GlxDrawable) GlxGetDrawableAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetDrawableAttributesRequest(Drawable), cookie) - return GlxGetDrawableAttributesCookie{cookie} -} - -func (c *Conn) GlxGetDrawableAttributesUnchecked(Drawable GlxDrawable) GlxGetDrawableAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetDrawableAttributesRequest(Drawable), cookie) - return GlxGetDrawableAttributesCookie{cookie} -} - -// Request reply for GlxGetDrawableAttributes -// size: (32 + pad(((int(NumAttribs) * 2) * 4))) -type GlxGetDrawableAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: pad(((int(NumAttribs) * 2) * 4)) -} - -// Waits and reads reply data from request GlxGetDrawableAttributes -func (cook GlxGetDrawableAttributesCookie) Reply() (*GlxGetDrawableAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetDrawableAttributesReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetDrawableAttributes -func glxGetDrawableAttributesReply(buf []byte) *GlxGetDrawableAttributesReply { - v := new(GlxGetDrawableAttributesReply) - 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.NumAttribs = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetDrawableAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetDrawableAttributes -func (c *Conn) glxGetDrawableAttributesRequest(Drawable GlxDrawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 29 // 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 GlxChangeDrawableAttributes -// size: pad((12 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxChangeDrawableAttributesCookie struct { - *cookie -} - -// Write request to wire for GlxChangeDrawableAttributes -func (c *Conn) GlxChangeDrawableAttributes(Drawable GlxDrawable, NumAttribs uint32, Attribs []uint32) GlxChangeDrawableAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxChangeDrawableAttributesRequest(Drawable, NumAttribs, Attribs), cookie) - return GlxChangeDrawableAttributesCookie{cookie} -} - -func (c *Conn) GlxChangeDrawableAttributesChecked(Drawable GlxDrawable, NumAttribs uint32, Attribs []uint32) GlxChangeDrawableAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxChangeDrawableAttributesRequest(Drawable, NumAttribs, Attribs), cookie) - return GlxChangeDrawableAttributesCookie{cookie} -} - -func (cook GlxChangeDrawableAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxChangeDrawableAttributes -func (c *Conn) glxChangeDrawableAttributesRequest(Drawable GlxDrawable, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((12 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 30 // 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:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxCreateWindow -// size: pad((24 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreateWindowCookie struct { - *cookie -} - -// Write request to wire for GlxCreateWindow -func (c *Conn) GlxCreateWindow(Screen uint32, Fbconfig GlxFbconfig, Window Window, GlxWindow GlxWindow, NumAttribs uint32, Attribs []uint32) GlxCreateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateWindowRequest(Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return GlxCreateWindowCookie{cookie} -} - -func (c *Conn) GlxCreateWindowChecked(Screen uint32, Fbconfig GlxFbconfig, Window Window, GlxWindow GlxWindow, NumAttribs uint32, Attribs []uint32) GlxCreateWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateWindowRequest(Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return GlxCreateWindowCookie{cookie} -} - -func (cook GlxCreateWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateWindow -func (c *Conn) glxCreateWindowRequest(Screen uint32, Fbconfig GlxFbconfig, Window Window, GlxWindow GlxWindow, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((24 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 31 // 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 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(GlxWindow)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDeleteWindow -// size: 8 -type GlxDeleteWindowCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteWindow -func (c *Conn) GlxDeleteWindow(Glxwindow GlxWindow) GlxDeleteWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteWindowRequest(Glxwindow), cookie) - return GlxDeleteWindowCookie{cookie} -} - -func (c *Conn) GlxDeleteWindowChecked(Glxwindow GlxWindow) GlxDeleteWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteWindowRequest(Glxwindow), cookie) - return GlxDeleteWindowCookie{cookie} -} - -func (cook GlxDeleteWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteWindow -func (c *Conn) glxDeleteWindowRequest(Glxwindow GlxWindow) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 32 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glxwindow)) - b += 4 - - return buf -} - -// Request GlxSetClientInfoARB -// size: pad((((24 + pad(((int(NumVersions) * 2) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) -type GlxSetClientInfoARBCookie struct { - *cookie -} - -// Write request to wire for GlxSetClientInfoARB -func (c *Conn) GlxSetClientInfoARB(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfoARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSetClientInfoARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfoARBCookie{cookie} -} - -func (c *Conn) GlxSetClientInfoARBChecked(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfoARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSetClientInfoARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfoARBCookie{cookie} -} - -func (cook GlxSetClientInfoARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSetClientInfoARB -func (c *Conn) glxSetClientInfoARBRequest(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { - size := pad((((24 + pad(((int(NumVersions) * 2) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 33 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - Put32(buf[b:], NumVersions) - b += 4 - - Put32(buf[b:], GlStrLen) - b += 4 - - Put32(buf[b:], GlxStrLen) - b += 4 - - for i := 0; i < int((int(NumVersions) * 2)); i++ { - Put32(buf[b:], GlVersions[i]) - b += 4 - } - b = pad(b) - - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += pad(int(GlStrLen)) - - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += pad(int(GlxStrLen)) - - return buf -} - -// Request GlxCreateContextAttribsARB -// size: pad((28 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreateContextAttribsARBCookie struct { - *cookie -} - -// Write request to wire for GlxCreateContextAttribsARB -func (c *Conn) GlxCreateContextAttribsARB(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, ShareList GlxContext, IsDirect bool, NumAttribs uint32, Attribs []uint32) GlxCreateContextAttribsARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateContextAttribsARBRequest(Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return GlxCreateContextAttribsARBCookie{cookie} -} - -func (c *Conn) GlxCreateContextAttribsARBChecked(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, ShareList GlxContext, IsDirect bool, NumAttribs uint32, Attribs []uint32) GlxCreateContextAttribsARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateContextAttribsARBRequest(Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return GlxCreateContextAttribsARBCookie{cookie} -} - -func (cook GlxCreateContextAttribsARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateContextAttribsARB -func (c *Conn) glxCreateContextAttribsARBRequest(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, ShareList GlxContext, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((28 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 34 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxSetClientInfo2ARB -// size: pad((((24 + pad(((int(NumVersions) * 3) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) -type GlxSetClientInfo2ARBCookie struct { - *cookie -} - -// Write request to wire for GlxSetClientInfo2ARB -func (c *Conn) GlxSetClientInfo2ARB(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfo2ARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSetClientInfo2ARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfo2ARBCookie{cookie} -} - -func (c *Conn) GlxSetClientInfo2ARBChecked(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfo2ARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSetClientInfo2ARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfo2ARBCookie{cookie} -} - -func (cook GlxSetClientInfo2ARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSetClientInfo2ARB -func (c *Conn) glxSetClientInfo2ARBRequest(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { - size := pad((((24 + pad(((int(NumVersions) * 3) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 35 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - Put32(buf[b:], NumVersions) - b += 4 - - Put32(buf[b:], GlStrLen) - b += 4 - - Put32(buf[b:], GlxStrLen) - b += 4 - - for i := 0; i < int((int(NumVersions) * 3)); i++ { - Put32(buf[b:], GlVersions[i]) - b += 4 - } - b = pad(b) - - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += pad(int(GlStrLen)) - - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += pad(int(GlxStrLen)) - - return buf -} - -// Request GlxNewList -// size: 16 -type GlxNewListCookie struct { - *cookie -} - -// Write request to wire for GlxNewList -func (c *Conn) GlxNewList(ContextTag GlxContextTag, List uint32, Mode uint32) GlxNewListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxNewListRequest(ContextTag, List, Mode), cookie) - return GlxNewListCookie{cookie} -} - -func (c *Conn) GlxNewListChecked(ContextTag GlxContextTag, List uint32, Mode uint32) GlxNewListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxNewListRequest(ContextTag, List, Mode), cookie) - return GlxNewListCookie{cookie} -} - -func (cook GlxNewListCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxNewList -func (c *Conn) glxNewListRequest(ContextTag GlxContextTag, List uint32, Mode uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 101 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], List) - b += 4 - - Put32(buf[b:], Mode) - b += 4 - - return buf -} - -// Request GlxEndList -// size: 8 -type GlxEndListCookie struct { - *cookie -} - -// Write request to wire for GlxEndList -func (c *Conn) GlxEndList(ContextTag GlxContextTag) GlxEndListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxEndListRequest(ContextTag), cookie) - return GlxEndListCookie{cookie} -} - -func (c *Conn) GlxEndListChecked(ContextTag GlxContextTag) GlxEndListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxEndListRequest(ContextTag), cookie) - return GlxEndListCookie{cookie} -} - -func (cook GlxEndListCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxEndList -func (c *Conn) glxEndListRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 102 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxDeleteLists -// size: 16 -type GlxDeleteListsCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteLists -func (c *Conn) GlxDeleteLists(ContextTag GlxContextTag, List uint32, Range int32) GlxDeleteListsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteListsRequest(ContextTag, List, Range), cookie) - return GlxDeleteListsCookie{cookie} -} - -func (c *Conn) GlxDeleteListsChecked(ContextTag GlxContextTag, List uint32, Range int32) GlxDeleteListsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteListsRequest(ContextTag, List, Range), cookie) - return GlxDeleteListsCookie{cookie} -} - -func (cook GlxDeleteListsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteLists -func (c *Conn) glxDeleteListsRequest(ContextTag GlxContextTag, List uint32, Range int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 103 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], List) - b += 4 - - Put32(buf[b:], uint32(Range)) - b += 4 - - return buf -} - -// Request GlxGenLists -// size: 12 -type GlxGenListsCookie struct { - *cookie -} - -func (c *Conn) GlxGenLists(ContextTag GlxContextTag, Range int32) GlxGenListsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGenListsRequest(ContextTag, Range), cookie) - return GlxGenListsCookie{cookie} -} - -func (c *Conn) GlxGenListsUnchecked(ContextTag GlxContextTag, Range int32) GlxGenListsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGenListsRequest(ContextTag, Range), cookie) - return GlxGenListsCookie{cookie} -} - -// Request reply for GlxGenLists -// size: 12 -type GlxGenListsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal uint32 -} - -// Waits and reads reply data from request GlxGenLists -func (cook GlxGenListsCookie) Reply() (*GlxGenListsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGenListsReply(buf), nil -} - -// Read reply into structure from buffer for GlxGenLists -func glxGenListsReply(buf []byte) *GlxGenListsReply { - v := new(GlxGenListsReply) - 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.RetVal = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook GlxGenListsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGenLists -func (c *Conn) glxGenListsRequest(ContextTag GlxContextTag, Range int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 104 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Range)) - b += 4 - - return buf -} - -// Request GlxFeedbackBuffer -// size: 16 -type GlxFeedbackBufferCookie struct { - *cookie -} - -// Write request to wire for GlxFeedbackBuffer -func (c *Conn) GlxFeedbackBuffer(ContextTag GlxContextTag, Size int32, Type int32) GlxFeedbackBufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxFeedbackBufferRequest(ContextTag, Size, Type), cookie) - return GlxFeedbackBufferCookie{cookie} -} - -func (c *Conn) GlxFeedbackBufferChecked(ContextTag GlxContextTag, Size int32, Type int32) GlxFeedbackBufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxFeedbackBufferRequest(ContextTag, Size, Type), cookie) - return GlxFeedbackBufferCookie{cookie} -} - -func (cook GlxFeedbackBufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxFeedbackBuffer -func (c *Conn) glxFeedbackBufferRequest(ContextTag GlxContextTag, Size int32, Type int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 105 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Size)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - return buf -} - -// Request GlxSelectBuffer -// size: 12 -type GlxSelectBufferCookie struct { - *cookie -} - -// Write request to wire for GlxSelectBuffer -func (c *Conn) GlxSelectBuffer(ContextTag GlxContextTag, Size int32) GlxSelectBufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSelectBufferRequest(ContextTag, Size), cookie) - return GlxSelectBufferCookie{cookie} -} - -func (c *Conn) GlxSelectBufferChecked(ContextTag GlxContextTag, Size int32) GlxSelectBufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSelectBufferRequest(ContextTag, Size), cookie) - return GlxSelectBufferCookie{cookie} -} - -func (cook GlxSelectBufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSelectBuffer -func (c *Conn) glxSelectBufferRequest(ContextTag GlxContextTag, Size int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 106 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Size)) - b += 4 - - return buf -} - -// Request GlxRenderMode -// size: 12 -type GlxRenderModeCookie struct { - *cookie -} - -func (c *Conn) GlxRenderMode(ContextTag GlxContextTag, Mode uint32) GlxRenderModeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxRenderModeRequest(ContextTag, Mode), cookie) - return GlxRenderModeCookie{cookie} -} - -func (c *Conn) GlxRenderModeUnchecked(ContextTag GlxContextTag, Mode uint32) GlxRenderModeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxRenderModeRequest(ContextTag, Mode), cookie) - return GlxRenderModeCookie{cookie} -} - -// Request reply for GlxRenderMode -// size: (32 + pad((int(N) * 4))) -type GlxRenderModeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal uint32 - N uint32 - NewMode uint32 - // padding: 12 bytes - Data []uint32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxRenderMode -func (cook GlxRenderModeCookie) Reply() (*GlxRenderModeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxRenderModeReply(buf), nil -} - -// Read reply into structure from buffer for GlxRenderMode -func glxRenderModeReply(buf []byte) *GlxRenderModeReply { - v := new(GlxRenderModeReply) - 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.RetVal = Get32(buf[b:]) - b += 4 - - v.N = Get32(buf[b:]) - b += 4 - - v.NewMode = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxRenderModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxRenderMode -func (c *Conn) glxRenderModeRequest(ContextTag GlxContextTag, Mode uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 107 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Mode) - b += 4 - - return buf -} - -// Request GlxFinish -// size: 8 -type GlxFinishCookie struct { - *cookie -} - -func (c *Conn) GlxFinish(ContextTag GlxContextTag) GlxFinishCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxFinishRequest(ContextTag), cookie) - return GlxFinishCookie{cookie} -} - -func (c *Conn) GlxFinishUnchecked(ContextTag GlxContextTag) GlxFinishCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxFinishRequest(ContextTag), cookie) - return GlxFinishCookie{cookie} -} - -// Request reply for GlxFinish -// size: 8 -type GlxFinishReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes -} - -// Waits and reads reply data from request GlxFinish -func (cook GlxFinishCookie) Reply() (*GlxFinishReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxFinishReply(buf), nil -} - -// Read reply into structure from buffer for GlxFinish -func glxFinishReply(buf []byte) *GlxFinishReply { - v := new(GlxFinishReply) - 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 - - return v -} - -func (cook GlxFinishCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxFinish -func (c *Conn) glxFinishRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 108 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxPixelStoref -// size: 16 -type GlxPixelStorefCookie struct { - *cookie -} - -// Write request to wire for GlxPixelStoref -func (c *Conn) GlxPixelStoref(ContextTag GlxContextTag, Pname uint32, Datum GlxFloat32) GlxPixelStorefCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxPixelStorefRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStorefCookie{cookie} -} - -func (c *Conn) GlxPixelStorefChecked(ContextTag GlxContextTag, Pname uint32, Datum GlxFloat32) GlxPixelStorefCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxPixelStorefRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStorefCookie{cookie} -} - -func (cook GlxPixelStorefCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxPixelStoref -func (c *Conn) glxPixelStorefRequest(ContextTag GlxContextTag, Pname uint32, Datum GlxFloat32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 109 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - Put32(buf[b:], uint32(Datum)) - b += 4 - - return buf -} - -// Request GlxPixelStorei -// size: 16 -type GlxPixelStoreiCookie struct { - *cookie -} - -// Write request to wire for GlxPixelStorei -func (c *Conn) GlxPixelStorei(ContextTag GlxContextTag, Pname uint32, Datum int32) GlxPixelStoreiCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxPixelStoreiRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStoreiCookie{cookie} -} - -func (c *Conn) GlxPixelStoreiChecked(ContextTag GlxContextTag, Pname uint32, Datum int32) GlxPixelStoreiCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxPixelStoreiRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStoreiCookie{cookie} -} - -func (cook GlxPixelStoreiCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxPixelStorei -func (c *Conn) glxPixelStoreiRequest(ContextTag GlxContextTag, Pname uint32, Datum int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 110 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - Put32(buf[b:], uint32(Datum)) - b += 4 - - return buf -} - -// Request GlxReadPixels -// size: 36 -type GlxReadPixelsCookie struct { - *cookie -} - -func (c *Conn) GlxReadPixels(ContextTag GlxContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) GlxReadPixelsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxReadPixelsRequest(ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) - return GlxReadPixelsCookie{cookie} -} - -func (c *Conn) GlxReadPixelsUnchecked(ContextTag GlxContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) GlxReadPixelsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxReadPixelsRequest(ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) - return GlxReadPixelsCookie{cookie} -} - -// Request reply for GlxReadPixels -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxReadPixelsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxReadPixels -func (cook GlxReadPixelsCookie) Reply() (*GlxReadPixelsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxReadPixelsReply(buf), nil -} - -// Read reply into structure from buffer for GlxReadPixels -func glxReadPixelsReply(buf []byte) *GlxReadPixelsReply { - v := new(GlxReadPixelsReply) - 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.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxReadPixelsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxReadPixels -func (c *Conn) glxReadPixelsRequest(ContextTag GlxContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 111 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(X)) - b += 4 - - Put32(buf[b:], uint32(Y)) - b += 4 - - Put32(buf[b:], uint32(Width)) - b += 4 - - Put32(buf[b:], uint32(Height)) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if LsbFirst { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetBooleanv -// size: 12 -type GlxGetBooleanvCookie struct { - *cookie -} - -func (c *Conn) GlxGetBooleanv(ContextTag GlxContextTag, Pname int32) GlxGetBooleanvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetBooleanvRequest(ContextTag, Pname), cookie) - return GlxGetBooleanvCookie{cookie} -} - -func (c *Conn) GlxGetBooleanvUnchecked(ContextTag GlxContextTag, Pname int32) GlxGetBooleanvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetBooleanvRequest(ContextTag, Pname), cookie) - return GlxGetBooleanvCookie{cookie} -} - -// Request reply for GlxGetBooleanv -// size: (32 + pad((int(N) * 1))) -type GlxGetBooleanvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum bool - // padding: 15 bytes - Data []bool // size: pad((int(N) * 1)) -} - -// Waits and reads reply data from request GlxGetBooleanv -func (cook GlxGetBooleanvCookie) Reply() (*GlxGetBooleanvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetBooleanvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetBooleanv -func glxGetBooleanvReply(buf []byte) *GlxGetBooleanvReply { - v := new(GlxGetBooleanvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - if buf[b] == 1 { - v.Datum = true - } else { - v.Datum = false - } - b += 1 - - b += 15 // padding - - v.Data = make([]bool, v.N) - for i := 0; i < int(v.N); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 - } - b = pad(b) - - return v -} - -func (cook GlxGetBooleanvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetBooleanv -func (c *Conn) glxGetBooleanvRequest(ContextTag GlxContextTag, Pname int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 112 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Pname)) - b += 4 - - return buf -} - -// Request GlxGetClipPlane -// size: 12 -type GlxGetClipPlaneCookie struct { - *cookie -} - -func (c *Conn) GlxGetClipPlane(ContextTag GlxContextTag, Plane int32) GlxGetClipPlaneCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetClipPlaneRequest(ContextTag, Plane), cookie) - return GlxGetClipPlaneCookie{cookie} -} - -func (c *Conn) GlxGetClipPlaneUnchecked(ContextTag GlxContextTag, Plane int32) GlxGetClipPlaneCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetClipPlaneRequest(ContextTag, Plane), cookie) - return GlxGetClipPlaneCookie{cookie} -} - -// Request reply for GlxGetClipPlane -// size: (32 + pad(((int(Length) / 2) * 8))) -type GlxGetClipPlaneReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []GlxFloat64 // size: pad(((int(Length) / 2) * 8)) -} - -// Waits and reads reply data from request GlxGetClipPlane -func (cook GlxGetClipPlaneCookie) Reply() (*GlxGetClipPlaneReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetClipPlaneReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetClipPlane -func glxGetClipPlaneReply(buf []byte) *GlxGetClipPlaneReply { - v := new(GlxGetClipPlaneReply) - 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.Data = make([]GlxFloat64, (int(v.Length) / 2)) - for i := 0; i < int((int(v.Length) / 2)); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetClipPlaneCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetClipPlane -func (c *Conn) glxGetClipPlaneRequest(ContextTag GlxContextTag, Plane int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 113 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Plane)) - b += 4 - - return buf -} - -// Request GlxGetDoublev -// size: 12 -type GlxGetDoublevCookie struct { - *cookie -} - -func (c *Conn) GlxGetDoublev(ContextTag GlxContextTag, Pname uint32) GlxGetDoublevCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetDoublevRequest(ContextTag, Pname), cookie) - return GlxGetDoublevCookie{cookie} -} - -func (c *Conn) GlxGetDoublevUnchecked(ContextTag GlxContextTag, Pname uint32) GlxGetDoublevCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetDoublevRequest(ContextTag, Pname), cookie) - return GlxGetDoublevCookie{cookie} -} - -// Request reply for GlxGetDoublev -// size: (32 + pad((int(N) * 8))) -type GlxGetDoublevReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat64 - // padding: 8 bytes - Data []GlxFloat64 // size: pad((int(N) * 8)) -} - -// Waits and reads reply data from request GlxGetDoublev -func (cook GlxGetDoublevCookie) Reply() (*GlxGetDoublevReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetDoublevReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetDoublev -func glxGetDoublevReply(buf []byte) *GlxGetDoublevReply { - v := new(GlxGetDoublevReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat64(Get64(buf[b:])) - b += 8 - - b += 8 // padding - - v.Data = make([]GlxFloat64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetDoublevCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetDoublev -func (c *Conn) glxGetDoublevRequest(ContextTag GlxContextTag, Pname uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 114 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetError -// size: 8 -type GlxGetErrorCookie struct { - *cookie -} - -func (c *Conn) GlxGetError(ContextTag GlxContextTag) GlxGetErrorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetErrorRequest(ContextTag), cookie) - return GlxGetErrorCookie{cookie} -} - -func (c *Conn) GlxGetErrorUnchecked(ContextTag GlxContextTag) GlxGetErrorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetErrorRequest(ContextTag), cookie) - return GlxGetErrorCookie{cookie} -} - -// Request reply for GlxGetError -// size: 12 -type GlxGetErrorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Error int32 -} - -// Waits and reads reply data from request GlxGetError -func (cook GlxGetErrorCookie) Reply() (*GlxGetErrorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetErrorReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetError -func glxGetErrorReply(buf []byte) *GlxGetErrorReply { - v := new(GlxGetErrorReply) - 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.Error = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxGetErrorCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetError -func (c *Conn) glxGetErrorRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 115 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxGetFloatv -// size: 12 -type GlxGetFloatvCookie struct { - *cookie -} - -func (c *Conn) GlxGetFloatv(ContextTag GlxContextTag, Pname uint32) GlxGetFloatvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetFloatvRequest(ContextTag, Pname), cookie) - return GlxGetFloatvCookie{cookie} -} - -func (c *Conn) GlxGetFloatvUnchecked(ContextTag GlxContextTag, Pname uint32) GlxGetFloatvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetFloatvRequest(ContextTag, Pname), cookie) - return GlxGetFloatvCookie{cookie} -} - -// Request reply for GlxGetFloatv -// size: (32 + pad((int(N) * 4))) -type GlxGetFloatvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetFloatv -func (cook GlxGetFloatvCookie) Reply() (*GlxGetFloatvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetFloatvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetFloatv -func glxGetFloatvReply(buf []byte) *GlxGetFloatvReply { - v := new(GlxGetFloatvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetFloatvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetFloatv -func (c *Conn) glxGetFloatvRequest(ContextTag GlxContextTag, Pname uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 116 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetIntegerv -// size: 12 -type GlxGetIntegervCookie struct { - *cookie -} - -func (c *Conn) GlxGetIntegerv(ContextTag GlxContextTag, Pname uint32) GlxGetIntegervCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetIntegervRequest(ContextTag, Pname), cookie) - return GlxGetIntegervCookie{cookie} -} - -func (c *Conn) GlxGetIntegervUnchecked(ContextTag GlxContextTag, Pname uint32) GlxGetIntegervCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetIntegervRequest(ContextTag, Pname), cookie) - return GlxGetIntegervCookie{cookie} -} - -// Request reply for GlxGetIntegerv -// size: (32 + pad((int(N) * 4))) -type GlxGetIntegervReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetIntegerv -func (cook GlxGetIntegervCookie) Reply() (*GlxGetIntegervReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetIntegervReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetIntegerv -func glxGetIntegervReply(buf []byte) *GlxGetIntegervReply { - v := new(GlxGetIntegervReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetIntegervCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetIntegerv -func (c *Conn) glxGetIntegervRequest(ContextTag GlxContextTag, Pname uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 117 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetLightfv -// size: 16 -type GlxGetLightfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetLightfv(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetLightfvRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightfvCookie{cookie} -} - -func (c *Conn) GlxGetLightfvUnchecked(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetLightfvRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightfvCookie{cookie} -} - -// Request reply for GlxGetLightfv -// size: (32 + pad((int(N) * 4))) -type GlxGetLightfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetLightfv -func (cook GlxGetLightfvCookie) Reply() (*GlxGetLightfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetLightfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetLightfv -func glxGetLightfvReply(buf []byte) *GlxGetLightfvReply { - v := new(GlxGetLightfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetLightfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetLightfv -func (c *Conn) glxGetLightfvRequest(ContextTag GlxContextTag, Light uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 118 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Light) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetLightiv -// size: 16 -type GlxGetLightivCookie struct { - *cookie -} - -func (c *Conn) GlxGetLightiv(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetLightivRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightivCookie{cookie} -} - -func (c *Conn) GlxGetLightivUnchecked(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetLightivRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightivCookie{cookie} -} - -// Request reply for GlxGetLightiv -// size: (32 + pad((int(N) * 4))) -type GlxGetLightivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetLightiv -func (cook GlxGetLightivCookie) Reply() (*GlxGetLightivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetLightivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetLightiv -func glxGetLightivReply(buf []byte) *GlxGetLightivReply { - v := new(GlxGetLightivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetLightivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetLightiv -func (c *Conn) glxGetLightivRequest(ContextTag GlxContextTag, Light uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 119 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Light) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMapdv -// size: 16 -type GlxGetMapdvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMapdv(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapdvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMapdvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapdvCookie{cookie} -} - -func (c *Conn) GlxGetMapdvUnchecked(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapdvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMapdvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapdvCookie{cookie} -} - -// Request reply for GlxGetMapdv -// size: (32 + pad((int(N) * 8))) -type GlxGetMapdvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat64 - // padding: 8 bytes - Data []GlxFloat64 // size: pad((int(N) * 8)) -} - -// Waits and reads reply data from request GlxGetMapdv -func (cook GlxGetMapdvCookie) Reply() (*GlxGetMapdvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMapdvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMapdv -func glxGetMapdvReply(buf []byte) *GlxGetMapdvReply { - v := new(GlxGetMapdvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat64(Get64(buf[b:])) - b += 8 - - b += 8 // padding - - v.Data = make([]GlxFloat64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetMapdvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMapdv -func (c *Conn) glxGetMapdvRequest(ContextTag GlxContextTag, Target uint32, Query uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 120 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Query) - b += 4 - - return buf -} - -// Request GlxGetMapfv -// size: 16 -type GlxGetMapfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMapfv(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMapfvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapfvCookie{cookie} -} - -func (c *Conn) GlxGetMapfvUnchecked(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMapfvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapfvCookie{cookie} -} - -// Request reply for GlxGetMapfv -// size: (32 + pad((int(N) * 4))) -type GlxGetMapfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMapfv -func (cook GlxGetMapfvCookie) Reply() (*GlxGetMapfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMapfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMapfv -func glxGetMapfvReply(buf []byte) *GlxGetMapfvReply { - v := new(GlxGetMapfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMapfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMapfv -func (c *Conn) glxGetMapfvRequest(ContextTag GlxContextTag, Target uint32, Query uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 121 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Query) - b += 4 - - return buf -} - -// Request GlxGetMapiv -// size: 16 -type GlxGetMapivCookie struct { - *cookie -} - -func (c *Conn) GlxGetMapiv(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMapivRequest(ContextTag, Target, Query), cookie) - return GlxGetMapivCookie{cookie} -} - -func (c *Conn) GlxGetMapivUnchecked(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMapivRequest(ContextTag, Target, Query), cookie) - return GlxGetMapivCookie{cookie} -} - -// Request reply for GlxGetMapiv -// size: (32 + pad((int(N) * 4))) -type GlxGetMapivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMapiv -func (cook GlxGetMapivCookie) Reply() (*GlxGetMapivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMapivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMapiv -func glxGetMapivReply(buf []byte) *GlxGetMapivReply { - v := new(GlxGetMapivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMapivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMapiv -func (c *Conn) glxGetMapivRequest(ContextTag GlxContextTag, Target uint32, Query uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 122 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Query) - b += 4 - - return buf -} - -// Request GlxGetMaterialfv -// size: 16 -type GlxGetMaterialfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMaterialfv(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMaterialfvRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialfvCookie{cookie} -} - -func (c *Conn) GlxGetMaterialfvUnchecked(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMaterialfvRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialfvCookie{cookie} -} - -// Request reply for GlxGetMaterialfv -// size: (32 + pad((int(N) * 4))) -type GlxGetMaterialfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMaterialfv -func (cook GlxGetMaterialfvCookie) Reply() (*GlxGetMaterialfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMaterialfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMaterialfv -func glxGetMaterialfvReply(buf []byte) *GlxGetMaterialfvReply { - v := new(GlxGetMaterialfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMaterialfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMaterialfv -func (c *Conn) glxGetMaterialfvRequest(ContextTag GlxContextTag, Face uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 123 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Face) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMaterialiv -// size: 16 -type GlxGetMaterialivCookie struct { - *cookie -} - -func (c *Conn) GlxGetMaterialiv(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMaterialivRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialivCookie{cookie} -} - -func (c *Conn) GlxGetMaterialivUnchecked(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMaterialivRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialivCookie{cookie} -} - -// Request reply for GlxGetMaterialiv -// size: (32 + pad((int(N) * 4))) -type GlxGetMaterialivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMaterialiv -func (cook GlxGetMaterialivCookie) Reply() (*GlxGetMaterialivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMaterialivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMaterialiv -func glxGetMaterialivReply(buf []byte) *GlxGetMaterialivReply { - v := new(GlxGetMaterialivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMaterialivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMaterialiv -func (c *Conn) glxGetMaterialivRequest(ContextTag GlxContextTag, Face uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 124 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Face) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetPixelMapfv -// size: 12 -type GlxGetPixelMapfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetPixelMapfv(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPixelMapfvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapfvCookie{cookie} -} - -func (c *Conn) GlxGetPixelMapfvUnchecked(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPixelMapfvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapfvCookie{cookie} -} - -// Request reply for GlxGetPixelMapfv -// size: (32 + pad((int(N) * 4))) -type GlxGetPixelMapfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetPixelMapfv -func (cook GlxGetPixelMapfvCookie) Reply() (*GlxGetPixelMapfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPixelMapfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPixelMapfv -func glxGetPixelMapfvReply(buf []byte) *GlxGetPixelMapfvReply { - v := new(GlxGetPixelMapfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetPixelMapfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPixelMapfv -func (c *Conn) glxGetPixelMapfvRequest(ContextTag GlxContextTag, Map uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 125 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Map) - b += 4 - - return buf -} - -// Request GlxGetPixelMapuiv -// size: 12 -type GlxGetPixelMapuivCookie struct { - *cookie -} - -func (c *Conn) GlxGetPixelMapuiv(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapuivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPixelMapuivRequest(ContextTag, Map), cookie) - return GlxGetPixelMapuivCookie{cookie} -} - -func (c *Conn) GlxGetPixelMapuivUnchecked(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapuivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPixelMapuivRequest(ContextTag, Map), cookie) - return GlxGetPixelMapuivCookie{cookie} -} - -// Request reply for GlxGetPixelMapuiv -// size: (32 + pad((int(N) * 4))) -type GlxGetPixelMapuivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint32 - // padding: 12 bytes - Data []uint32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetPixelMapuiv -func (cook GlxGetPixelMapuivCookie) Reply() (*GlxGetPixelMapuivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPixelMapuivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPixelMapuiv -func glxGetPixelMapuivReply(buf []byte) *GlxGetPixelMapuivReply { - v := new(GlxGetPixelMapuivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetPixelMapuivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPixelMapuiv -func (c *Conn) glxGetPixelMapuivRequest(ContextTag GlxContextTag, Map uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 126 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Map) - b += 4 - - return buf -} - -// Request GlxGetPixelMapusv -// size: 12 -type GlxGetPixelMapusvCookie struct { - *cookie -} - -func (c *Conn) GlxGetPixelMapusv(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapusvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPixelMapusvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapusvCookie{cookie} -} - -func (c *Conn) GlxGetPixelMapusvUnchecked(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapusvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPixelMapusvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapusvCookie{cookie} -} - -// Request reply for GlxGetPixelMapusv -// size: (34 + pad((int(N) * 2))) -type GlxGetPixelMapusvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint16 - // padding: 16 bytes - Data []uint16 // size: pad((int(N) * 2)) -} - -// Waits and reads reply data from request GlxGetPixelMapusv -func (cook GlxGetPixelMapusvCookie) Reply() (*GlxGetPixelMapusvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPixelMapusvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPixelMapusv -func glxGetPixelMapusvReply(buf []byte) *GlxGetPixelMapusvReply { - v := new(GlxGetPixelMapusvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = Get16(buf[b:]) - b += 2 - - b += 16 // padding - - v.Data = make([]uint16, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return v -} - -func (cook GlxGetPixelMapusvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPixelMapusv -func (c *Conn) glxGetPixelMapusvRequest(ContextTag GlxContextTag, Map uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 127 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Map) - b += 4 - - return buf -} - -// Request GlxGetPolygonStipple -// size: 12 -type GlxGetPolygonStippleCookie struct { - *cookie -} - -func (c *Conn) GlxGetPolygonStipple(ContextTag GlxContextTag, LsbFirst bool) GlxGetPolygonStippleCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPolygonStippleRequest(ContextTag, LsbFirst), cookie) - return GlxGetPolygonStippleCookie{cookie} -} - -func (c *Conn) GlxGetPolygonStippleUnchecked(ContextTag GlxContextTag, LsbFirst bool) GlxGetPolygonStippleCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPolygonStippleRequest(ContextTag, LsbFirst), cookie) - return GlxGetPolygonStippleCookie{cookie} -} - -// Request reply for GlxGetPolygonStipple -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetPolygonStippleReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetPolygonStipple -func (cook GlxGetPolygonStippleCookie) Reply() (*GlxGetPolygonStippleReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPolygonStippleReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPolygonStipple -func glxGetPolygonStippleReply(buf []byte) *GlxGetPolygonStippleReply { - v := new(GlxGetPolygonStippleReply) - 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.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetPolygonStippleCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPolygonStipple -func (c *Conn) glxGetPolygonStippleRequest(ContextTag GlxContextTag, LsbFirst bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 128 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - if LsbFirst { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetString -// size: 12 -type GlxGetStringCookie struct { - *cookie -} - -func (c *Conn) GlxGetString(ContextTag GlxContextTag, Name uint32) GlxGetStringCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetStringRequest(ContextTag, Name), cookie) - return GlxGetStringCookie{cookie} -} - -func (c *Conn) GlxGetStringUnchecked(ContextTag GlxContextTag, Name uint32) GlxGetStringCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetStringRequest(ContextTag, Name), cookie) - return GlxGetStringCookie{cookie} -} - -// Request reply for GlxGetString -// size: (32 + pad((int(N) * 1))) -type GlxGetStringReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - // padding: 16 bytes - String string // size: pad((int(N) * 1)) -} - -// Waits and reads reply data from request GlxGetString -func (cook GlxGetStringCookie) Reply() (*GlxGetStringReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetStringReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetString -func glxGetStringReply(buf []byte) *GlxGetStringReply { - v := new(GlxGetStringReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.N) - copy(byteString[:v.N], buf[b:]) - v.String = string(byteString) - b += pad(int(v.N)) - } - - return v -} - -func (cook GlxGetStringCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetString -func (c *Conn) glxGetStringRequest(ContextTag GlxContextTag, Name uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 129 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Name) - b += 4 - - return buf -} - -// Request GlxGetTexEnvfv -// size: 16 -type GlxGetTexEnvfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexEnvfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexEnvfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvfvCookie{cookie} -} - -func (c *Conn) GlxGetTexEnvfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexEnvfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvfvCookie{cookie} -} - -// Request reply for GlxGetTexEnvfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexEnvfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexEnvfv -func (cook GlxGetTexEnvfvCookie) Reply() (*GlxGetTexEnvfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexEnvfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexEnvfv -func glxGetTexEnvfvReply(buf []byte) *GlxGetTexEnvfvReply { - v := new(GlxGetTexEnvfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexEnvfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexEnvfv -func (c *Conn) glxGetTexEnvfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 130 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexEnviv -// size: 16 -type GlxGetTexEnvivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexEnviv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexEnvivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvivCookie{cookie} -} - -func (c *Conn) GlxGetTexEnvivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexEnvivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvivCookie{cookie} -} - -// Request reply for GlxGetTexEnviv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexEnvivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexEnviv -func (cook GlxGetTexEnvivCookie) Reply() (*GlxGetTexEnvivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexEnvivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexEnviv -func glxGetTexEnvivReply(buf []byte) *GlxGetTexEnvivReply { - v := new(GlxGetTexEnvivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexEnvivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexEnviv -func (c *Conn) glxGetTexEnvivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 131 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexGendv -// size: 16 -type GlxGetTexGendvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexGendv(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGendvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexGendvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGendvCookie{cookie} -} - -func (c *Conn) GlxGetTexGendvUnchecked(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGendvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexGendvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGendvCookie{cookie} -} - -// Request reply for GlxGetTexGendv -// size: (32 + pad((int(N) * 8))) -type GlxGetTexGendvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat64 - // padding: 8 bytes - Data []GlxFloat64 // size: pad((int(N) * 8)) -} - -// Waits and reads reply data from request GlxGetTexGendv -func (cook GlxGetTexGendvCookie) Reply() (*GlxGetTexGendvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexGendvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexGendv -func glxGetTexGendvReply(buf []byte) *GlxGetTexGendvReply { - v := new(GlxGetTexGendvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat64(Get64(buf[b:])) - b += 8 - - b += 8 // padding - - v.Data = make([]GlxFloat64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexGendvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexGendv -func (c *Conn) glxGetTexGendvRequest(ContextTag GlxContextTag, Coord uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 132 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Coord) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexGenfv -// size: 16 -type GlxGetTexGenfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexGenfv(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexGenfvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenfvCookie{cookie} -} - -func (c *Conn) GlxGetTexGenfvUnchecked(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexGenfvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenfvCookie{cookie} -} - -// Request reply for GlxGetTexGenfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexGenfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexGenfv -func (cook GlxGetTexGenfvCookie) Reply() (*GlxGetTexGenfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexGenfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexGenfv -func glxGetTexGenfvReply(buf []byte) *GlxGetTexGenfvReply { - v := new(GlxGetTexGenfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexGenfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexGenfv -func (c *Conn) glxGetTexGenfvRequest(ContextTag GlxContextTag, Coord uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 133 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Coord) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexGeniv -// size: 16 -type GlxGetTexGenivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexGeniv(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexGenivRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenivCookie{cookie} -} - -func (c *Conn) GlxGetTexGenivUnchecked(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexGenivRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenivCookie{cookie} -} - -// Request reply for GlxGetTexGeniv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexGenivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexGeniv -func (cook GlxGetTexGenivCookie) Reply() (*GlxGetTexGenivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexGenivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexGeniv -func glxGetTexGenivReply(buf []byte) *GlxGetTexGenivReply { - v := new(GlxGetTexGenivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexGenivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexGeniv -func (c *Conn) glxGetTexGenivRequest(ContextTag GlxContextTag, Coord uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 134 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Coord) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexImage -// size: 28 -type GlxGetTexImageCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexImage(ContextTag GlxContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GlxGetTexImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexImageRequest(ContextTag, Target, Level, Format, Type, SwapBytes), cookie) - return GlxGetTexImageCookie{cookie} -} - -func (c *Conn) GlxGetTexImageUnchecked(ContextTag GlxContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GlxGetTexImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexImageRequest(ContextTag, Target, Level, Format, Type, SwapBytes), cookie) - return GlxGetTexImageCookie{cookie} -} - -// Request reply for GlxGetTexImage -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetTexImageReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - Height int32 - Depth int32 - // padding: 4 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetTexImage -func (cook GlxGetTexImageCookie) Reply() (*GlxGetTexImageReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexImageReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexImage -func glxGetTexImageReply(buf []byte) *GlxGetTexImageReply { - v := new(GlxGetTexImageReply) - 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 += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - v.Height = int32(Get32(buf[b:])) - b += 4 - - v.Depth = int32(Get32(buf[b:])) - b += 4 - - b += 4 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetTexImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexImage -func (c *Conn) glxGetTexImageRequest(ContextTag GlxContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 135 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetTexParameterfv -// size: 16 -type GlxGetTexParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetTexParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterfvCookie{cookie} -} - -// Request reply for GlxGetTexParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexParameterfv -func (cook GlxGetTexParameterfvCookie) Reply() (*GlxGetTexParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexParameterfv -func glxGetTexParameterfvReply(buf []byte) *GlxGetTexParameterfvReply { - v := new(GlxGetTexParameterfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexParameterfv -func (c *Conn) glxGetTexParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 136 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexParameteriv -// size: 16 -type GlxGetTexParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterivCookie{cookie} -} - -func (c *Conn) GlxGetTexParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterivCookie{cookie} -} - -// Request reply for GlxGetTexParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexParameteriv -func (cook GlxGetTexParameterivCookie) Reply() (*GlxGetTexParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexParameteriv -func glxGetTexParameterivReply(buf []byte) *GlxGetTexParameterivReply { - v := new(GlxGetTexParameterivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexParameteriv -func (c *Conn) glxGetTexParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 137 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexLevelParameterfv -// size: 20 -type GlxGetTexLevelParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexLevelParameterfv(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexLevelParameterfvRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetTexLevelParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexLevelParameterfvRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterfvCookie{cookie} -} - -// Request reply for GlxGetTexLevelParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexLevelParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexLevelParameterfv -func (cook GlxGetTexLevelParameterfvCookie) Reply() (*GlxGetTexLevelParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexLevelParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexLevelParameterfv -func glxGetTexLevelParameterfvReply(buf []byte) *GlxGetTexLevelParameterfvReply { - v := new(GlxGetTexLevelParameterfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexLevelParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexLevelParameterfv -func (c *Conn) glxGetTexLevelParameterfvRequest(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 138 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexLevelParameteriv -// size: 20 -type GlxGetTexLevelParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexLevelParameteriv(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexLevelParameterivRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterivCookie{cookie} -} - -func (c *Conn) GlxGetTexLevelParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexLevelParameterivRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterivCookie{cookie} -} - -// Request reply for GlxGetTexLevelParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexLevelParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexLevelParameteriv -func (cook GlxGetTexLevelParameterivCookie) Reply() (*GlxGetTexLevelParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexLevelParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexLevelParameteriv -func glxGetTexLevelParameterivReply(buf []byte) *GlxGetTexLevelParameterivReply { - v := new(GlxGetTexLevelParameterivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexLevelParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexLevelParameteriv -func (c *Conn) glxGetTexLevelParameterivRequest(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 139 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxIsList -// size: 12 -type GlxIsListCookie struct { - *cookie -} - -func (c *Conn) GlxIsList(ContextTag GlxContextTag, List uint32) GlxIsListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsListRequest(ContextTag, List), cookie) - return GlxIsListCookie{cookie} -} - -func (c *Conn) GlxIsListUnchecked(ContextTag GlxContextTag, List uint32) GlxIsListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsListRequest(ContextTag, List), cookie) - return GlxIsListCookie{cookie} -} - -// Request reply for GlxIsList -// size: 12 -type GlxIsListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 -} - -// Waits and reads reply data from request GlxIsList -func (cook GlxIsListCookie) Reply() (*GlxIsListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsListReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsList -func glxIsListReply(buf []byte) *GlxIsListReply { - v := new(GlxIsListReply) - 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.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxIsListCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsList -func (c *Conn) glxIsListRequest(ContextTag GlxContextTag, List uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 141 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], List) - b += 4 - - return buf -} - -// Request GlxFlush -// size: 8 -type GlxFlushCookie struct { - *cookie -} - -// Write request to wire for GlxFlush -func (c *Conn) GlxFlush(ContextTag GlxContextTag) GlxFlushCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxFlushRequest(ContextTag), cookie) - return GlxFlushCookie{cookie} -} - -func (c *Conn) GlxFlushChecked(ContextTag GlxContextTag) GlxFlushCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxFlushRequest(ContextTag), cookie) - return GlxFlushCookie{cookie} -} - -func (cook GlxFlushCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxFlush -func (c *Conn) glxFlushRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 142 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxAreTexturesResident -// size: pad((12 + pad((int(N) * 4)))) -type GlxAreTexturesResidentCookie struct { - *cookie -} - -func (c *Conn) GlxAreTexturesResident(ContextTag GlxContextTag, N int32, Textures []uint32) GlxAreTexturesResidentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxAreTexturesResidentRequest(ContextTag, N, Textures), cookie) - return GlxAreTexturesResidentCookie{cookie} -} - -func (c *Conn) GlxAreTexturesResidentUnchecked(ContextTag GlxContextTag, N int32, Textures []uint32) GlxAreTexturesResidentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxAreTexturesResidentRequest(ContextTag, N, Textures), cookie) - return GlxAreTexturesResidentCookie{cookie} -} - -// Request reply for GlxAreTexturesResident -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxAreTexturesResidentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 - // padding: 20 bytes - Data []bool // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxAreTexturesResident -func (cook GlxAreTexturesResidentCookie) Reply() (*GlxAreTexturesResidentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxAreTexturesResidentReply(buf), nil -} - -// Read reply into structure from buffer for GlxAreTexturesResident -func glxAreTexturesResidentReply(buf []byte) *GlxAreTexturesResidentReply { - v := new(GlxAreTexturesResidentReply) - 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.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]bool, (int(v.Length) * 4)) - for i := 0; i < int((int(v.Length) * 4)); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 - } - b = pad(b) - - return v -} - -func (cook GlxAreTexturesResidentCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxAreTexturesResident -func (c *Conn) glxAreTexturesResidentRequest(ContextTag GlxContextTag, N int32, Textures []uint32) []byte { - size := pad((12 + pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 143 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - Put32(buf[b:], Textures[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDeleteTextures -// size: pad((12 + pad((int(N) * 4)))) -type GlxDeleteTexturesCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteTextures -func (c *Conn) GlxDeleteTextures(ContextTag GlxContextTag, N int32, Textures []uint32) GlxDeleteTexturesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteTexturesRequest(ContextTag, N, Textures), cookie) - return GlxDeleteTexturesCookie{cookie} -} - -func (c *Conn) GlxDeleteTexturesChecked(ContextTag GlxContextTag, N int32, Textures []uint32) GlxDeleteTexturesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteTexturesRequest(ContextTag, N, Textures), cookie) - return GlxDeleteTexturesCookie{cookie} -} - -func (cook GlxDeleteTexturesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteTextures -func (c *Conn) glxDeleteTexturesRequest(ContextTag GlxContextTag, N int32, Textures []uint32) []byte { - size := pad((12 + pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 144 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - Put32(buf[b:], Textures[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxGenTextures -// size: 12 -type GlxGenTexturesCookie struct { - *cookie -} - -func (c *Conn) GlxGenTextures(ContextTag GlxContextTag, N int32) GlxGenTexturesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGenTexturesRequest(ContextTag, N), cookie) - return GlxGenTexturesCookie{cookie} -} - -func (c *Conn) GlxGenTexturesUnchecked(ContextTag GlxContextTag, N int32) GlxGenTexturesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGenTexturesRequest(ContextTag, N), cookie) - return GlxGenTexturesCookie{cookie} -} - -// Request reply for GlxGenTextures -// size: (32 + pad((int(Length) * 4))) -type GlxGenTexturesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGenTextures -func (cook GlxGenTexturesCookie) Reply() (*GlxGenTexturesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGenTexturesReply(buf), nil -} - -// Read reply into structure from buffer for GlxGenTextures -func glxGenTexturesReply(buf []byte) *GlxGenTexturesReply { - v := new(GlxGenTexturesReply) - 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.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGenTexturesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGenTextures -func (c *Conn) glxGenTexturesRequest(ContextTag GlxContextTag, N int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 145 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - return buf -} - -// Request GlxIsTexture -// size: 12 -type GlxIsTextureCookie struct { - *cookie -} - -func (c *Conn) GlxIsTexture(ContextTag GlxContextTag, Texture uint32) GlxIsTextureCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsTextureRequest(ContextTag, Texture), cookie) - return GlxIsTextureCookie{cookie} -} - -func (c *Conn) GlxIsTextureUnchecked(ContextTag GlxContextTag, Texture uint32) GlxIsTextureCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsTextureRequest(ContextTag, Texture), cookie) - return GlxIsTextureCookie{cookie} -} - -// Request reply for GlxIsTexture -// size: 12 -type GlxIsTextureReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 -} - -// Waits and reads reply data from request GlxIsTexture -func (cook GlxIsTextureCookie) Reply() (*GlxIsTextureReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsTextureReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsTexture -func glxIsTextureReply(buf []byte) *GlxIsTextureReply { - v := new(GlxIsTextureReply) - 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.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxIsTextureCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsTexture -func (c *Conn) glxIsTextureRequest(ContextTag GlxContextTag, Texture uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 146 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Texture) - b += 4 - - return buf -} - -// Request GlxGetColorTable -// size: 24 -type GlxGetColorTableCookie struct { - *cookie -} - -func (c *Conn) GlxGetColorTable(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetColorTableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetColorTableRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetColorTableCookie{cookie} -} - -func (c *Conn) GlxGetColorTableUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetColorTableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetColorTableRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetColorTableCookie{cookie} -} - -// Request reply for GlxGetColorTable -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetColorTableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - // padding: 12 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetColorTable -func (cook GlxGetColorTableCookie) Reply() (*GlxGetColorTableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetColorTableReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetColorTable -func glxGetColorTableReply(buf []byte) *GlxGetColorTableReply { - v := new(GlxGetColorTableReply) - 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 += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetColorTableCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetColorTable -func (c *Conn) glxGetColorTableRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 147 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetColorTableParameterfv -// size: 16 -type GlxGetColorTableParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetColorTableParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetColorTableParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetColorTableParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetColorTableParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterfvCookie{cookie} -} - -// Request reply for GlxGetColorTableParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetColorTableParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetColorTableParameterfv -func (cook GlxGetColorTableParameterfvCookie) Reply() (*GlxGetColorTableParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetColorTableParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetColorTableParameterfv -func glxGetColorTableParameterfvReply(buf []byte) *GlxGetColorTableParameterfvReply { - v := new(GlxGetColorTableParameterfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetColorTableParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetColorTableParameterfv -func (c *Conn) glxGetColorTableParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 148 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetColorTableParameteriv -// size: 16 -type GlxGetColorTableParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetColorTableParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetColorTableParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterivCookie{cookie} -} - -func (c *Conn) GlxGetColorTableParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetColorTableParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterivCookie{cookie} -} - -// Request reply for GlxGetColorTableParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetColorTableParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetColorTableParameteriv -func (cook GlxGetColorTableParameterivCookie) Reply() (*GlxGetColorTableParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetColorTableParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetColorTableParameteriv -func glxGetColorTableParameterivReply(buf []byte) *GlxGetColorTableParameterivReply { - v := new(GlxGetColorTableParameterivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetColorTableParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetColorTableParameteriv -func (c *Conn) glxGetColorTableParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 149 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetConvolutionFilter -// size: 24 -type GlxGetConvolutionFilterCookie struct { - *cookie -} - -func (c *Conn) GlxGetConvolutionFilter(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetConvolutionFilterCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetConvolutionFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetConvolutionFilterCookie{cookie} -} - -func (c *Conn) GlxGetConvolutionFilterUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetConvolutionFilterCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetConvolutionFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetConvolutionFilterCookie{cookie} -} - -// Request reply for GlxGetConvolutionFilter -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetConvolutionFilterReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - Height int32 - // padding: 8 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetConvolutionFilter -func (cook GlxGetConvolutionFilterCookie) Reply() (*GlxGetConvolutionFilterReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetConvolutionFilterReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetConvolutionFilter -func glxGetConvolutionFilterReply(buf []byte) *GlxGetConvolutionFilterReply { - v := new(GlxGetConvolutionFilterReply) - 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 += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - v.Height = int32(Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetConvolutionFilterCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetConvolutionFilter -func (c *Conn) glxGetConvolutionFilterRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 150 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetConvolutionParameterfv -// size: 16 -type GlxGetConvolutionParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetConvolutionParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetConvolutionParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetConvolutionParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetConvolutionParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterfvCookie{cookie} -} - -// Request reply for GlxGetConvolutionParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetConvolutionParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetConvolutionParameterfv -func (cook GlxGetConvolutionParameterfvCookie) Reply() (*GlxGetConvolutionParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetConvolutionParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetConvolutionParameterfv -func glxGetConvolutionParameterfvReply(buf []byte) *GlxGetConvolutionParameterfvReply { - v := new(GlxGetConvolutionParameterfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetConvolutionParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetConvolutionParameterfv -func (c *Conn) glxGetConvolutionParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 151 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetConvolutionParameteriv -// size: 16 -type GlxGetConvolutionParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetConvolutionParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetConvolutionParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterivCookie{cookie} -} - -func (c *Conn) GlxGetConvolutionParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetConvolutionParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterivCookie{cookie} -} - -// Request reply for GlxGetConvolutionParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetConvolutionParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetConvolutionParameteriv -func (cook GlxGetConvolutionParameterivCookie) Reply() (*GlxGetConvolutionParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetConvolutionParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetConvolutionParameteriv -func glxGetConvolutionParameterivReply(buf []byte) *GlxGetConvolutionParameterivReply { - v := new(GlxGetConvolutionParameterivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetConvolutionParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetConvolutionParameteriv -func (c *Conn) glxGetConvolutionParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 152 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetSeparableFilter -// size: 24 -type GlxGetSeparableFilterCookie struct { - *cookie -} - -func (c *Conn) GlxGetSeparableFilter(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetSeparableFilterCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetSeparableFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetSeparableFilterCookie{cookie} -} - -func (c *Conn) GlxGetSeparableFilterUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetSeparableFilterCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetSeparableFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetSeparableFilterCookie{cookie} -} - -// Request reply for GlxGetSeparableFilter -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetSeparableFilterReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - RowW int32 - ColH int32 - // padding: 8 bytes - RowsAndCols []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetSeparableFilter -func (cook GlxGetSeparableFilterCookie) Reply() (*GlxGetSeparableFilterReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetSeparableFilterReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetSeparableFilter -func glxGetSeparableFilterReply(buf []byte) *GlxGetSeparableFilterReply { - v := new(GlxGetSeparableFilterReply) - 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 += 8 // padding - - v.RowW = int32(Get32(buf[b:])) - b += 4 - - v.ColH = int32(Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.RowsAndCols = make([]byte, (int(v.Length) * 4)) - copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetSeparableFilterCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetSeparableFilter -func (c *Conn) glxGetSeparableFilterRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 153 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetHistogram -// size: 24 -type GlxGetHistogramCookie struct { - *cookie -} - -func (c *Conn) GlxGetHistogram(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetHistogramCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetHistogramRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetHistogramCookie{cookie} -} - -func (c *Conn) GlxGetHistogramUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetHistogramCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetHistogramRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetHistogramCookie{cookie} -} - -// Request reply for GlxGetHistogram -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetHistogramReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - // padding: 12 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetHistogram -func (cook GlxGetHistogramCookie) Reply() (*GlxGetHistogramReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetHistogramReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetHistogram -func glxGetHistogramReply(buf []byte) *GlxGetHistogramReply { - v := new(GlxGetHistogramReply) - 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 += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetHistogramCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetHistogram -func (c *Conn) glxGetHistogramRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 154 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetHistogramParameterfv -// size: 16 -type GlxGetHistogramParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetHistogramParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetHistogramParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetHistogramParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetHistogramParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterfvCookie{cookie} -} - -// Request reply for GlxGetHistogramParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetHistogramParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetHistogramParameterfv -func (cook GlxGetHistogramParameterfvCookie) Reply() (*GlxGetHistogramParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetHistogramParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetHistogramParameterfv -func glxGetHistogramParameterfvReply(buf []byte) *GlxGetHistogramParameterfvReply { - v := new(GlxGetHistogramParameterfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetHistogramParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetHistogramParameterfv -func (c *Conn) glxGetHistogramParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 155 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetHistogramParameteriv -// size: 16 -type GlxGetHistogramParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetHistogramParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetHistogramParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterivCookie{cookie} -} - -func (c *Conn) GlxGetHistogramParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetHistogramParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterivCookie{cookie} -} - -// Request reply for GlxGetHistogramParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetHistogramParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetHistogramParameteriv -func (cook GlxGetHistogramParameterivCookie) Reply() (*GlxGetHistogramParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetHistogramParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetHistogramParameteriv -func glxGetHistogramParameterivReply(buf []byte) *GlxGetHistogramParameterivReply { - v := new(GlxGetHistogramParameterivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetHistogramParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetHistogramParameteriv -func (c *Conn) glxGetHistogramParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 156 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMinmax -// size: 24 -type GlxGetMinmaxCookie struct { - *cookie -} - -func (c *Conn) GlxGetMinmax(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetMinmaxCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMinmaxRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetMinmaxCookie{cookie} -} - -func (c *Conn) GlxGetMinmaxUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetMinmaxCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMinmaxRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetMinmaxCookie{cookie} -} - -// Request reply for GlxGetMinmax -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetMinmaxReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetMinmax -func (cook GlxGetMinmaxCookie) Reply() (*GlxGetMinmaxReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMinmaxReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMinmax -func glxGetMinmaxReply(buf []byte) *GlxGetMinmaxReply { - v := new(GlxGetMinmaxReply) - 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.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetMinmaxCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMinmax -func (c *Conn) glxGetMinmaxRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 157 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetMinmaxParameterfv -// size: 16 -type GlxGetMinmaxParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMinmaxParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMinmaxParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetMinmaxParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMinmaxParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterfvCookie{cookie} -} - -// Request reply for GlxGetMinmaxParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetMinmaxParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMinmaxParameterfv -func (cook GlxGetMinmaxParameterfvCookie) Reply() (*GlxGetMinmaxParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMinmaxParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMinmaxParameterfv -func glxGetMinmaxParameterfvReply(buf []byte) *GlxGetMinmaxParameterfvReply { - v := new(GlxGetMinmaxParameterfvReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMinmaxParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMinmaxParameterfv -func (c *Conn) glxGetMinmaxParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 158 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMinmaxParameteriv -// size: 16 -type GlxGetMinmaxParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetMinmaxParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMinmaxParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterivCookie{cookie} -} - -func (c *Conn) GlxGetMinmaxParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMinmaxParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterivCookie{cookie} -} - -// Request reply for GlxGetMinmaxParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetMinmaxParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMinmaxParameteriv -func (cook GlxGetMinmaxParameterivCookie) Reply() (*GlxGetMinmaxParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMinmaxParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMinmaxParameteriv -func glxGetMinmaxParameterivReply(buf []byte) *GlxGetMinmaxParameterivReply { - v := new(GlxGetMinmaxParameterivReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMinmaxParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMinmaxParameteriv -func (c *Conn) glxGetMinmaxParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 159 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetCompressedTexImageARB -// size: 16 -type GlxGetCompressedTexImageARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetCompressedTexImageARB(ContextTag GlxContextTag, Target uint32, Level int32) GlxGetCompressedTexImageARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetCompressedTexImageARBRequest(ContextTag, Target, Level), cookie) - return GlxGetCompressedTexImageARBCookie{cookie} -} - -func (c *Conn) GlxGetCompressedTexImageARBUnchecked(ContextTag GlxContextTag, Target uint32, Level int32) GlxGetCompressedTexImageARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetCompressedTexImageARBRequest(ContextTag, Target, Level), cookie) - return GlxGetCompressedTexImageARBCookie{cookie} -} - -// Request reply for GlxGetCompressedTexImageARB -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetCompressedTexImageARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Size int32 - // padding: 12 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetCompressedTexImageARB -func (cook GlxGetCompressedTexImageARBCookie) Reply() (*GlxGetCompressedTexImageARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetCompressedTexImageARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetCompressedTexImageARB -func glxGetCompressedTexImageARBReply(buf []byte) *GlxGetCompressedTexImageARBReply { - v := new(GlxGetCompressedTexImageARBReply) - 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 += 8 // padding - - v.Size = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetCompressedTexImageARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetCompressedTexImageARB -func (c *Conn) glxGetCompressedTexImageARBRequest(ContextTag GlxContextTag, Target uint32, Level int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 160 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - return buf -} - -// Request GlxDeleteQueriesARB -// size: pad((12 + pad((int(N) * 4)))) -type GlxDeleteQueriesARBCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteQueriesARB -func (c *Conn) GlxDeleteQueriesARB(ContextTag GlxContextTag, N int32, Ids []uint32) GlxDeleteQueriesARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteQueriesARBRequest(ContextTag, N, Ids), cookie) - return GlxDeleteQueriesARBCookie{cookie} -} - -func (c *Conn) GlxDeleteQueriesARBChecked(ContextTag GlxContextTag, N int32, Ids []uint32) GlxDeleteQueriesARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteQueriesARBRequest(ContextTag, N, Ids), cookie) - return GlxDeleteQueriesARBCookie{cookie} -} - -func (cook GlxDeleteQueriesARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteQueriesARB -func (c *Conn) glxDeleteQueriesARBRequest(ContextTag GlxContextTag, N int32, Ids []uint32) []byte { - size := pad((12 + pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 161 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - Put32(buf[b:], Ids[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxGenQueriesARB -// size: 12 -type GlxGenQueriesARBCookie struct { - *cookie -} - -func (c *Conn) GlxGenQueriesARB(ContextTag GlxContextTag, N int32) GlxGenQueriesARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGenQueriesARBRequest(ContextTag, N), cookie) - return GlxGenQueriesARBCookie{cookie} -} - -func (c *Conn) GlxGenQueriesARBUnchecked(ContextTag GlxContextTag, N int32) GlxGenQueriesARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGenQueriesARBRequest(ContextTag, N), cookie) - return GlxGenQueriesARBCookie{cookie} -} - -// Request reply for GlxGenQueriesARB -// size: (32 + pad((int(Length) * 4))) -type GlxGenQueriesARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGenQueriesARB -func (cook GlxGenQueriesARBCookie) Reply() (*GlxGenQueriesARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGenQueriesARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGenQueriesARB -func glxGenQueriesARBReply(buf []byte) *GlxGenQueriesARBReply { - v := new(GlxGenQueriesARBReply) - 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.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGenQueriesARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGenQueriesARB -func (c *Conn) glxGenQueriesARBRequest(ContextTag GlxContextTag, N int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 162 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - return buf -} - -// Request GlxIsQueryARB -// size: 12 -type GlxIsQueryARBCookie struct { - *cookie -} - -func (c *Conn) GlxIsQueryARB(ContextTag GlxContextTag, Id uint32) GlxIsQueryARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsQueryARBRequest(ContextTag, Id), cookie) - return GlxIsQueryARBCookie{cookie} -} - -func (c *Conn) GlxIsQueryARBUnchecked(ContextTag GlxContextTag, Id uint32) GlxIsQueryARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsQueryARBRequest(ContextTag, Id), cookie) - return GlxIsQueryARBCookie{cookie} -} - -// Request reply for GlxIsQueryARB -// size: 12 -type GlxIsQueryARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 -} - -// Waits and reads reply data from request GlxIsQueryARB -func (cook GlxIsQueryARBCookie) Reply() (*GlxIsQueryARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsQueryARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsQueryARB -func glxIsQueryARBReply(buf []byte) *GlxIsQueryARBReply { - v := new(GlxIsQueryARBReply) - 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.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxIsQueryARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsQueryARB -func (c *Conn) glxIsQueryARBRequest(ContextTag GlxContextTag, Id uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 163 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - return buf -} - -// Request GlxGetQueryivARB -// size: 16 -type GlxGetQueryivARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetQueryivARB(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetQueryivARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetQueryivARBRequest(ContextTag, Target, Pname), cookie) - return GlxGetQueryivARBCookie{cookie} -} - -func (c *Conn) GlxGetQueryivARBUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetQueryivARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetQueryivARBRequest(ContextTag, Target, Pname), cookie) - return GlxGetQueryivARBCookie{cookie} -} - -// Request reply for GlxGetQueryivARB -// size: (32 + pad((int(N) * 4))) -type GlxGetQueryivARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetQueryivARB -func (cook GlxGetQueryivARBCookie) Reply() (*GlxGetQueryivARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetQueryivARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetQueryivARB -func glxGetQueryivARBReply(buf []byte) *GlxGetQueryivARBReply { - v := new(GlxGetQueryivARBReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetQueryivARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetQueryivARB -func (c *Conn) glxGetQueryivARBRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 164 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetQueryObjectivARB -// size: 16 -type GlxGetQueryObjectivARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetQueryObjectivARB(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectivARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetQueryObjectivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectivARBCookie{cookie} -} - -func (c *Conn) GlxGetQueryObjectivARBUnchecked(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectivARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetQueryObjectivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectivARBCookie{cookie} -} - -// Request reply for GlxGetQueryObjectivARB -// size: (32 + pad((int(N) * 4))) -type GlxGetQueryObjectivARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetQueryObjectivARB -func (cook GlxGetQueryObjectivARBCookie) Reply() (*GlxGetQueryObjectivARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetQueryObjectivARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetQueryObjectivARB -func glxGetQueryObjectivARBReply(buf []byte) *GlxGetQueryObjectivARBReply { - v := new(GlxGetQueryObjectivARBReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetQueryObjectivARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetQueryObjectivARB -func (c *Conn) glxGetQueryObjectivARBRequest(ContextTag GlxContextTag, Id uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 165 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetQueryObjectuivARB -// size: 16 -type GlxGetQueryObjectuivARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetQueryObjectuivARB(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectuivARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetQueryObjectuivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectuivARBCookie{cookie} -} - -func (c *Conn) GlxGetQueryObjectuivARBUnchecked(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectuivARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetQueryObjectuivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectuivARBCookie{cookie} -} - -// Request reply for GlxGetQueryObjectuivARB -// size: (32 + pad((int(N) * 4))) -type GlxGetQueryObjectuivARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint32 - // padding: 12 bytes - Data []uint32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetQueryObjectuivARB -func (cook GlxGetQueryObjectuivARBCookie) Reply() (*GlxGetQueryObjectuivARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetQueryObjectuivARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetQueryObjectuivARB -func glxGetQueryObjectuivARBReply(buf []byte) *GlxGetQueryObjectuivARBReply { - v := new(GlxGetQueryObjectuivARBReply) - 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 += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetQueryObjectuivARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetQueryObjectuivARB -func (c *Conn) glxGetQueryObjectuivARBRequest(ContextTag GlxContextTag, Id uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 166 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} diff --git a/nexgb/auto_randr.go b/nexgb/auto_randr.go deleted file mode 100644 index d7e68bd..0000000 --- a/nexgb/auto_randr.go +++ /dev/null @@ -1,4038 +0,0 @@ -package xgb - -/* - This file was generated by randr.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 "render" - -// RandrInit must be called before using the RANDR extension. -func (c *Conn) RandrInit() error { - reply, err := c.QueryExtension(5, "RANDR").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named RANDR could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["RANDR"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["RANDR"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["RANDR"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["RANDR"] = make(map[int]newEventFun) - newExtErrorFuncs["RANDR"] = 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 ( - RandrRotationRotate0 = 1 - RandrRotationRotate90 = 2 - RandrRotationRotate180 = 4 - RandrRotationRotate270 = 8 - RandrRotationReflectX = 16 - RandrRotationReflectY = 32 -) - -const ( - RandrSetConfigSuccess = 0 - RandrSetConfigInvalidConfigTime = 1 - RandrSetConfigInvalidTime = 2 - RandrSetConfigFailed = 3 -) - -const ( - RandrNotifyMaskScreenChange = 1 - RandrNotifyMaskCrtcChange = 2 - RandrNotifyMaskOutputChange = 4 - RandrNotifyMaskOutputProperty = 8 -) - -const ( - RandrModeFlagHsyncPositive = 1 - RandrModeFlagHsyncNegative = 2 - RandrModeFlagVsyncPositive = 4 - RandrModeFlagVsyncNegative = 8 - RandrModeFlagInterlace = 16 - RandrModeFlagDoubleScan = 32 - RandrModeFlagCsync = 64 - RandrModeFlagCsyncPositive = 128 - RandrModeFlagCsyncNegative = 256 - RandrModeFlagHskewPresent = 512 - RandrModeFlagBcast = 1024 - RandrModeFlagPixelMultiplex = 2048 - RandrModeFlagDoubleClock = 4096 - RandrModeFlagHalveClock = 8192 -) - -const ( - RandrConnectionConnected = 0 - RandrConnectionDisconnected = 1 - RandrConnectionUnknown = 2 -) - -const ( - RandrNotifyCrtcChange = 0 - RandrNotifyOutputChange = 1 - RandrNotifyOutputProperty = 2 -) - -type RandrMode uint32 - -func (c *Conn) NewRandrModeId() (RandrMode, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RandrMode(id), nil -} - -type RandrCrtc uint32 - -func (c *Conn) NewRandrCrtcId() (RandrCrtc, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RandrCrtc(id), nil -} - -type RandrOutput uint32 - -func (c *Conn) NewRandrOutputId() (RandrOutput, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RandrOutput(id), nil -} - -// 'RandrScreenSize' struct definition -// Size: 8 -type RandrScreenSize struct { - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 -} - -// Struct read RandrScreenSize -func ReadRandrScreenSize(buf []byte, v *RandrScreenSize) int { - b := 0 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Mwidth = Get16(buf[b:]) - b += 2 - - v.Mheight = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RandrScreenSize -func ReadRandrScreenSizeList(buf []byte, dest []RandrScreenSize) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrScreenSize{} - b += ReadRandrScreenSize(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrScreenSize -func (v RandrScreenSize) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Mwidth) - b += 2 - - Put16(buf[b:], v.Mheight) - b += 2 - - return buf -} - -// Write struct list RandrScreenSize -func RandrScreenSizeListBytes(buf []byte, list []RandrScreenSize) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrRefreshRates' struct definition -// Size: (2 + pad((int(NRates) * 2))) -type RandrRefreshRates struct { - NRates uint16 - Rates []uint16 // size: pad((int(NRates) * 2)) -} - -// Struct read RandrRefreshRates -func ReadRandrRefreshRates(buf []byte, v *RandrRefreshRates) int { - b := 0 - - v.NRates = Get16(buf[b:]) - b += 2 - - v.Rates = make([]uint16, v.NRates) - for i := 0; i < int(v.NRates); i++ { - v.Rates[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return b -} - -// Struct list read RandrRefreshRates -func ReadRandrRefreshRatesList(buf []byte, dest []RandrRefreshRates) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrRefreshRates{} - b += ReadRandrRefreshRates(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrRefreshRates -func (v RandrRefreshRates) Bytes() []byte { - buf := make([]byte, (2 + pad((int(v.NRates) * 2)))) - b := 0 - - Put16(buf[b:], v.NRates) - b += 2 - - for i := 0; i < int(v.NRates); i++ { - Put16(buf[b:], v.Rates[i]) - b += 2 - } - b = pad(b) - - return buf -} - -// Write struct list RandrRefreshRates -func RandrRefreshRatesListBytes(buf []byte, list []RandrRefreshRates) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RandrRefreshRates -func RandrRefreshRatesListSize(list []RandrRefreshRates) int { - size := 0 - for _, item := range list { - size += (2 + pad((int(item.NRates) * 2))) - } - return size -} - -// 'RandrModeInfo' struct definition -// Size: 32 -type RandrModeInfo struct { - Id uint32 - Width uint16 - Height uint16 - DotClock uint32 - HsyncStart uint16 - HsyncEnd uint16 - Htotal uint16 - Hskew uint16 - VsyncStart uint16 - VsyncEnd uint16 - Vtotal uint16 - NameLen uint16 - ModeFlags uint32 -} - -// Struct read RandrModeInfo -func ReadRandrModeInfo(buf []byte, v *RandrModeInfo) int { - b := 0 - - v.Id = Get32(buf[b:]) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.DotClock = Get32(buf[b:]) - b += 4 - - v.HsyncStart = Get16(buf[b:]) - b += 2 - - v.HsyncEnd = Get16(buf[b:]) - b += 2 - - v.Htotal = Get16(buf[b:]) - b += 2 - - v.Hskew = Get16(buf[b:]) - b += 2 - - v.VsyncStart = Get16(buf[b:]) - b += 2 - - v.VsyncEnd = Get16(buf[b:]) - b += 2 - - v.Vtotal = Get16(buf[b:]) - b += 2 - - v.NameLen = Get16(buf[b:]) - b += 2 - - v.ModeFlags = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read RandrModeInfo -func ReadRandrModeInfoList(buf []byte, dest []RandrModeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrModeInfo{} - b += ReadRandrModeInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrModeInfo -func (v RandrModeInfo) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - Put32(buf[b:], v.Id) - b += 4 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put32(buf[b:], v.DotClock) - b += 4 - - Put16(buf[b:], v.HsyncStart) - b += 2 - - Put16(buf[b:], v.HsyncEnd) - b += 2 - - Put16(buf[b:], v.Htotal) - b += 2 - - Put16(buf[b:], v.Hskew) - b += 2 - - Put16(buf[b:], v.VsyncStart) - b += 2 - - Put16(buf[b:], v.VsyncEnd) - b += 2 - - Put16(buf[b:], v.Vtotal) - b += 2 - - Put16(buf[b:], v.NameLen) - b += 2 - - Put32(buf[b:], v.ModeFlags) - b += 4 - - return buf -} - -// Write struct list RandrModeInfo -func RandrModeInfoListBytes(buf []byte, list []RandrModeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrCrtcChange' struct definition -// Size: 28 -type RandrCrtcChange struct { - Timestamp Timestamp - Window Window - Crtc RandrCrtc - Mode RandrMode - Rotation uint16 - // padding: 2 bytes - X int16 - Y int16 - Width uint16 - Height uint16 -} - -// Struct read RandrCrtcChange -func ReadRandrCrtcChange(buf []byte, v *RandrCrtcChange) int { - b := 0 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Crtc = RandrCrtc(Get32(buf[b:])) - b += 4 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - v.Rotation = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = 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 RandrCrtcChange -func ReadRandrCrtcChangeList(buf []byte, dest []RandrCrtcChange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrCrtcChange -func (v RandrCrtcChange) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Crtc)) - b += 4 - - Put32(buf[b:], uint32(v.Mode)) - b += 4 - - Put16(buf[b:], v.Rotation) - b += 2 - - b += 2 // padding - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// Write struct list RandrCrtcChange -func RandrCrtcChangeListBytes(buf []byte, list []RandrCrtcChange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrOutputChange' struct definition -// Size: 28 -type RandrOutputChange struct { - Timestamp Timestamp - ConfigTimestamp Timestamp - Window Window - Output RandrOutput - Crtc RandrCrtc - Mode RandrMode - Rotation uint16 - Connection byte - SubpixelOrder byte -} - -// Struct read RandrOutputChange -func ReadRandrOutputChange(buf []byte, v *RandrOutputChange) int { - b := 0 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Output = RandrOutput(Get32(buf[b:])) - b += 4 - - v.Crtc = RandrCrtc(Get32(buf[b:])) - b += 4 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - v.Rotation = Get16(buf[b:]) - b += 2 - - v.Connection = buf[b] - b += 1 - - v.SubpixelOrder = buf[b] - b += 1 - - return b -} - -// Struct list read RandrOutputChange -func ReadRandrOutputChangeList(buf []byte, dest []RandrOutputChange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrOutputChange -func (v RandrOutputChange) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.ConfigTimestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Output)) - b += 4 - - Put32(buf[b:], uint32(v.Crtc)) - b += 4 - - Put32(buf[b:], uint32(v.Mode)) - b += 4 - - Put16(buf[b:], v.Rotation) - b += 2 - - buf[b] = v.Connection - b += 1 - - buf[b] = v.SubpixelOrder - b += 1 - - return buf -} - -// Write struct list RandrOutputChange -func RandrOutputChangeListBytes(buf []byte, list []RandrOutputChange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrOutputProperty' struct definition -// Size: 28 -type RandrOutputProperty struct { - Window Window - Output RandrOutput - Atom Atom - Timestamp Timestamp - Status byte - // padding: 11 bytes -} - -// Struct read RandrOutputProperty -func ReadRandrOutputProperty(buf []byte, v *RandrOutputProperty) int { - b := 0 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Output = RandrOutput(Get32(buf[b:])) - b += 4 - - v.Atom = Atom(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Status = buf[b] - b += 1 - - b += 11 // padding - - return b -} - -// Struct list read RandrOutputProperty -func ReadRandrOutputPropertyList(buf []byte, dest []RandrOutputProperty) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrOutputProperty -func (v RandrOutputProperty) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Output)) - b += 4 - - Put32(buf[b:], uint32(v.Atom)) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - buf[b] = v.Status - b += 1 - - b += 11 // padding - - return buf -} - -// Write struct list RandrOutputProperty -func RandrOutputPropertyListBytes(buf []byte, list []RandrOutputProperty) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Union definition RandrNotifyDataUnion -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'RandrNotifyDataUnion': -// NewRandrNotifyDataUnionCc(Cc RandrCrtcChange) RandrNotifyDataUnion -// NewRandrNotifyDataUnionOc(Oc RandrOutputChange) RandrNotifyDataUnion -// NewRandrNotifyDataUnionOp(Op RandrOutputProperty) RandrNotifyDataUnion -type RandrNotifyDataUnion struct { - Cc RandrCrtcChange - Oc RandrOutputChange - Op RandrOutputProperty -} - -// Union constructor for RandrNotifyDataUnion for field Cc. -func NewRandrNotifyDataUnionCc(Cc RandrCrtcChange) RandrNotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Cc.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - // Create the Union type - v := RandrNotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return v -} - -// Union constructor for RandrNotifyDataUnion for field Oc. -func NewRandrNotifyDataUnionOc(Oc RandrOutputChange) RandrNotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Oc.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - // Create the Union type - v := RandrNotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return v -} - -// Union constructor for RandrNotifyDataUnion for field Op. -func NewRandrNotifyDataUnionOp(Op RandrOutputProperty) RandrNotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Op.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - // Create the Union type - v := RandrNotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return v -} - -// Union read RandrNotifyDataUnion -func ReadRandrNotifyDataUnion(buf []byte, v *RandrNotifyDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // re-read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // re-read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return 28 -} - -// Union list read RandrNotifyDataUnion -func ReadRandrNotifyDataUnionList(buf []byte, dest []RandrNotifyDataUnion) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrNotifyDataUnion{} - b += ReadRandrNotifyDataUnion(buf[b:], &dest[i]) - } - return pad(b) -} - -// Union write RandrNotifyDataUnion -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v RandrNotifyDataUnion) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - { - structBytes := v.Cc.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return buf -} - -// Union list write RandrNotifyDataUnion -func RandrNotifyDataUnionListBytes(buf []byte, list []RandrNotifyDataUnion) int { - b := 0 - var unionBytes []byte - for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - return b -} - -// Event definition RandrScreenChangeNotify (0) -// Size: 32 - -const RandrScreenChangeNotify = 0 - -type RandrScreenChangeNotifyEvent struct { - Sequence uint16 - Rotation byte - Timestamp Timestamp - ConfigTimestamp Timestamp - Root Window - RequestWindow Window - SizeID uint16 - SubpixelOrder uint16 - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 -} - -// Event read RandrScreenChangeNotify -func NewRandrScreenChangeNotifyEvent(buf []byte) Event { - v := RandrScreenChangeNotifyEvent{} - b := 1 // don't read event number - - v.Rotation = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.RequestWindow = Window(Get32(buf[b:])) - b += 4 - - v.SizeID = Get16(buf[b:]) - b += 2 - - v.SubpixelOrder = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Mwidth = Get16(buf[b:]) - b += 2 - - v.Mheight = Get16(buf[b:]) - b += 2 - - return v -} - -// Event write RandrScreenChangeNotify -func (v RandrScreenChangeNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Rotation - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.ConfigTimestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.RequestWindow)) - b += 4 - - Put16(buf[b:], v.SizeID) - b += 2 - - Put16(buf[b:], v.SubpixelOrder) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Mwidth) - b += 2 - - Put16(buf[b:], v.Mheight) - b += 2 - - return buf -} - -func (v RandrScreenChangeNotifyEvent) ImplementsEvent() {} - -func (v RandrScreenChangeNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v RandrScreenChangeNotifyEvent) String() string { - fieldVals := make([]string, 0, 11) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Rotation: %d", v.Rotation)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("ConfigTimestamp: %d", v.ConfigTimestamp)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("RequestWindow: %d", v.RequestWindow)) - fieldVals = append(fieldVals, sprintf("SizeID: %d", v.SizeID)) - fieldVals = append(fieldVals, sprintf("SubpixelOrder: %d", v.SubpixelOrder)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("Mwidth: %d", v.Mwidth)) - fieldVals = append(fieldVals, sprintf("Mheight: %d", v.Mheight)) - return "RandrScreenChangeNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["RANDR"][0] = NewRandrScreenChangeNotifyEvent -} - -// Event definition RandrNotify (1) -// Size: 32 - -const RandrNotify = 1 - -type RandrNotifyEvent struct { - Sequence uint16 - SubCode byte - U RandrNotifyDataUnion -} - -// Event read RandrNotify -func NewRandrNotifyEvent(buf []byte) Event { - v := RandrNotifyEvent{} - b := 1 // don't read event number - - v.SubCode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.U = RandrNotifyDataUnion{} - b += ReadRandrNotifyDataUnion(buf[b:], &v.U) - - return v -} - -// Event write RandrNotify -func (v RandrNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.SubCode - b += 1 - - b += 2 // skip sequence number - - { - unionBytes := v.U.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - - return buf -} - -func (v RandrNotifyEvent) ImplementsEvent() {} - -func (v RandrNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v RandrNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("SubCode: %d", v.SubCode)) - return "RandrNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["RANDR"][1] = NewRandrNotifyEvent -} - -// Error definition RandrBadOutput (0) -// Size: 32 - -const BadRandrBadOutput = 0 - -type RandrBadOutputError struct { - Sequence uint16 - NiceName string -} - -// Error read RandrBadOutput -func NewRandrBadOutputError(buf []byte) Error { - v := RandrBadOutputError{} - v.NiceName = "RandrBadOutput" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RandrBadOutputError) ImplementsError() {} - -func (err RandrBadOutputError) SequenceId() uint16 { - return err.Sequence -} - -func (err RandrBadOutputError) BadId() uint32 { - return 0 -} - -func (err RandrBadOutputError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRandrBadOutput {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RANDR"][0] = NewRandrBadOutputError -} - -// Error definition RandrBadCrtc (1) -// Size: 32 - -const BadRandrBadCrtc = 1 - -type RandrBadCrtcError struct { - Sequence uint16 - NiceName string -} - -// Error read RandrBadCrtc -func NewRandrBadCrtcError(buf []byte) Error { - v := RandrBadCrtcError{} - v.NiceName = "RandrBadCrtc" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RandrBadCrtcError) ImplementsError() {} - -func (err RandrBadCrtcError) SequenceId() uint16 { - return err.Sequence -} - -func (err RandrBadCrtcError) BadId() uint32 { - return 0 -} - -func (err RandrBadCrtcError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRandrBadCrtc {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RANDR"][1] = NewRandrBadCrtcError -} - -// Error definition RandrBadMode (2) -// Size: 32 - -const BadRandrBadMode = 2 - -type RandrBadModeError struct { - Sequence uint16 - NiceName string -} - -// Error read RandrBadMode -func NewRandrBadModeError(buf []byte) Error { - v := RandrBadModeError{} - v.NiceName = "RandrBadMode" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RandrBadModeError) ImplementsError() {} - -func (err RandrBadModeError) SequenceId() uint16 { - return err.Sequence -} - -func (err RandrBadModeError) BadId() uint32 { - return 0 -} - -func (err RandrBadModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRandrBadMode {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RANDR"][2] = NewRandrBadModeError -} - -// Request RandrQueryVersion -// size: 12 -type RandrQueryVersionCookie struct { - *cookie -} - -func (c *Conn) RandrQueryVersion(MajorVersion uint32, MinorVersion uint32) RandrQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RandrQueryVersionCookie{cookie} -} - -func (c *Conn) RandrQueryVersionUnchecked(MajorVersion uint32, MinorVersion uint32) RandrQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RandrQueryVersionCookie{cookie} -} - -// Request reply for RandrQueryVersion -// size: 32 -type RandrQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request RandrQueryVersion -func (cook RandrQueryVersionCookie) Reply() (*RandrQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for RandrQueryVersion -func randrQueryVersionReply(buf []byte) *RandrQueryVersionReply { - v := new(RandrQueryVersionReply) - 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 RandrQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrQueryVersion -func (c *Conn) randrQueryVersionRequest(MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// Request RandrSetScreenConfig -// size: 24 -type RandrSetScreenConfigCookie struct { - *cookie -} - -func (c *Conn) RandrSetScreenConfig(Window Window, Timestamp Timestamp, ConfigTimestamp Timestamp, SizeID uint16, Rotation uint16, Rate uint16) RandrSetScreenConfigCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrSetScreenConfigRequest(Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return RandrSetScreenConfigCookie{cookie} -} - -func (c *Conn) RandrSetScreenConfigUnchecked(Window Window, Timestamp Timestamp, ConfigTimestamp Timestamp, SizeID uint16, Rotation uint16, Rate uint16) RandrSetScreenConfigCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrSetScreenConfigRequest(Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return RandrSetScreenConfigCookie{cookie} -} - -// Request reply for RandrSetScreenConfig -// size: 32 -type RandrSetScreenConfigReply struct { - Sequence uint16 - Length uint32 - Status byte - NewTimestamp Timestamp - ConfigTimestamp Timestamp - Root Window - SubpixelOrder uint16 - // padding: 10 bytes -} - -// Waits and reads reply data from request RandrSetScreenConfig -func (cook RandrSetScreenConfigCookie) Reply() (*RandrSetScreenConfigReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrSetScreenConfigReply(buf), nil -} - -// Read reply into structure from buffer for RandrSetScreenConfig -func randrSetScreenConfigReply(buf []byte) *RandrSetScreenConfigReply { - v := new(RandrSetScreenConfigReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NewTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.SubpixelOrder = Get16(buf[b:]) - b += 2 - - b += 10 // padding - - return v -} - -func (cook RandrSetScreenConfigCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetScreenConfig -func (c *Conn) randrSetScreenConfigRequest(Window Window, Timestamp Timestamp, ConfigTimestamp Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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 - - Put32(buf[b:], uint32(Timestamp)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - Put16(buf[b:], SizeID) - b += 2 - - Put16(buf[b:], Rotation) - b += 2 - - Put16(buf[b:], Rate) - b += 2 - - b += 2 // padding - - return buf -} - -// Request RandrSelectInput -// size: 12 -type RandrSelectInputCookie struct { - *cookie -} - -// Write request to wire for RandrSelectInput -func (c *Conn) RandrSelectInput(Window Window, Enable uint16) RandrSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSelectInputRequest(Window, Enable), cookie) - return RandrSelectInputCookie{cookie} -} - -func (c *Conn) RandrSelectInputChecked(Window Window, Enable uint16) RandrSelectInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSelectInputRequest(Window, Enable), cookie) - return RandrSelectInputCookie{cookie} -} - -func (cook RandrSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSelectInput -func (c *Conn) randrSelectInputRequest(Window Window, Enable uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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 - - Put16(buf[b:], Enable) - b += 2 - - b += 2 // padding - - return buf -} - -// Request RandrGetScreenInfo -// size: 8 -type RandrGetScreenInfoCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenInfo(Window Window) RandrGetScreenInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenInfoRequest(Window), cookie) - return RandrGetScreenInfoCookie{cookie} -} - -func (c *Conn) RandrGetScreenInfoUnchecked(Window Window) RandrGetScreenInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenInfoRequest(Window), cookie) - return RandrGetScreenInfoCookie{cookie} -} - -// Request reply for RandrGetScreenInfo -// size: ((32 + pad((int(NSizes) * 8))) + RandrRefreshRatesListSize(Rates)) -type RandrGetScreenInfoReply struct { - Sequence uint16 - Length uint32 - Rotations byte - Root Window - Timestamp Timestamp - ConfigTimestamp Timestamp - NSizes uint16 - SizeID uint16 - Rotation uint16 - Rate uint16 - NInfo uint16 - // padding: 2 bytes - Sizes []RandrScreenSize // size: pad((int(NSizes) * 8)) - Rates []RandrRefreshRates // size: RandrRefreshRatesListSize(Rates) -} - -// Waits and reads reply data from request RandrGetScreenInfo -func (cook RandrGetScreenInfoCookie) Reply() (*RandrGetScreenInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenInfoReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenInfo -func randrGetScreenInfoReply(buf []byte) *RandrGetScreenInfoReply { - v := new(RandrGetScreenInfoReply) - b := 1 // skip reply determinant - - v.Rotations = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.NSizes = Get16(buf[b:]) - b += 2 - - v.SizeID = Get16(buf[b:]) - b += 2 - - v.Rotation = Get16(buf[b:]) - b += 2 - - v.Rate = Get16(buf[b:]) - b += 2 - - v.NInfo = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Sizes = make([]RandrScreenSize, v.NSizes) - b += ReadRandrScreenSizeList(buf[b:], v.Sizes) - - v.Rates = make([]RandrRefreshRates, (int(v.NInfo) - int(v.NSizes))) - b += ReadRandrRefreshRatesList(buf[b:], v.Rates) - - return v -} - -func (cook RandrGetScreenInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenInfo -func (c *Conn) randrGetScreenInfoRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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(Window)) - b += 4 - - return buf -} - -// Request RandrGetScreenSizeRange -// size: 8 -type RandrGetScreenSizeRangeCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenSizeRange(Window Window) RandrGetScreenSizeRangeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenSizeRangeRequest(Window), cookie) - return RandrGetScreenSizeRangeCookie{cookie} -} - -func (c *Conn) RandrGetScreenSizeRangeUnchecked(Window Window) RandrGetScreenSizeRangeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenSizeRangeRequest(Window), cookie) - return RandrGetScreenSizeRangeCookie{cookie} -} - -// Request reply for RandrGetScreenSizeRange -// size: 32 -type RandrGetScreenSizeRangeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MinWidth uint16 - MinHeight uint16 - MaxWidth uint16 - MaxHeight uint16 - // padding: 16 bytes -} - -// Waits and reads reply data from request RandrGetScreenSizeRange -func (cook RandrGetScreenSizeRangeCookie) Reply() (*RandrGetScreenSizeRangeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenSizeRangeReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenSizeRange -func randrGetScreenSizeRangeReply(buf []byte) *RandrGetScreenSizeRangeReply { - v := new(RandrGetScreenSizeRangeReply) - 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.MinWidth = Get16(buf[b:]) - b += 2 - - v.MinHeight = Get16(buf[b:]) - b += 2 - - v.MaxWidth = Get16(buf[b:]) - b += 2 - - v.MaxHeight = Get16(buf[b:]) - b += 2 - - b += 16 // padding - - return v -} - -func (cook RandrGetScreenSizeRangeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenSizeRange -func (c *Conn) randrGetScreenSizeRangeRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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 - - return buf -} - -// Request RandrSetScreenSize -// size: 20 -type RandrSetScreenSizeCookie struct { - *cookie -} - -// Write request to wire for RandrSetScreenSize -func (c *Conn) RandrSetScreenSize(Window Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) RandrSetScreenSizeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetScreenSizeRequest(Window, Width, Height, MmWidth, MmHeight), cookie) - return RandrSetScreenSizeCookie{cookie} -} - -func (c *Conn) RandrSetScreenSizeChecked(Window Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) RandrSetScreenSizeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetScreenSizeRequest(Window, Width, Height, MmWidth, MmHeight), cookie) - return RandrSetScreenSizeCookie{cookie} -} - -func (cook RandrSetScreenSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetScreenSize -func (c *Conn) randrSetScreenSizeRequest(Window Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], MmWidth) - b += 4 - - Put32(buf[b:], MmHeight) - b += 4 - - return buf -} - -// Request RandrGetScreenResources -// size: 8 -type RandrGetScreenResourcesCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenResources(Window Window) RandrGetScreenResourcesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenResourcesRequest(Window), cookie) - return RandrGetScreenResourcesCookie{cookie} -} - -func (c *Conn) RandrGetScreenResourcesUnchecked(Window Window) RandrGetScreenResourcesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenResourcesRequest(Window), cookie) - return RandrGetScreenResourcesCookie{cookie} -} - -// Request reply for RandrGetScreenResources -// size: ((((32 + pad((int(NumCrtcs) * 4))) + pad((int(NumOutputs) * 4))) + pad((int(NumModes) * 32))) + pad((int(NamesLen) * 1))) -type RandrGetScreenResourcesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Timestamp Timestamp - ConfigTimestamp Timestamp - NumCrtcs uint16 - NumOutputs uint16 - NumModes uint16 - NamesLen uint16 - // padding: 8 bytes - Crtcs []RandrCrtc // size: pad((int(NumCrtcs) * 4)) - Outputs []RandrOutput // size: pad((int(NumOutputs) * 4)) - Modes []RandrModeInfo // size: pad((int(NumModes) * 32)) - Names []byte // size: pad((int(NamesLen) * 1)) -} - -// Waits and reads reply data from request RandrGetScreenResources -func (cook RandrGetScreenResourcesCookie) Reply() (*RandrGetScreenResourcesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenResourcesReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenResources -func randrGetScreenResourcesReply(buf []byte) *RandrGetScreenResourcesReply { - v := new(RandrGetScreenResourcesReply) - 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.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.NumCrtcs = Get16(buf[b:]) - b += 2 - - v.NumOutputs = Get16(buf[b:]) - b += 2 - - v.NumModes = Get16(buf[b:]) - b += 2 - - v.NamesLen = Get16(buf[b:]) - b += 2 - - b += 8 // padding - - v.Crtcs = make([]RandrCrtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = RandrCrtc(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Outputs = make([]RandrOutput, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]RandrModeInfo, v.NumModes) - b += ReadRandrModeInfoList(buf[b:], v.Modes) - - v.Names = make([]byte, v.NamesLen) - copy(v.Names[:v.NamesLen], buf[b:]) - b += pad(int(v.NamesLen)) - - return v -} - -func (cook RandrGetScreenResourcesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenResources -func (c *Conn) randrGetScreenResourcesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - 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 -} - -// Request RandrGetOutputInfo -// size: 12 -type RandrGetOutputInfoCookie struct { - *cookie -} - -func (c *Conn) RandrGetOutputInfo(Output RandrOutput, ConfigTimestamp Timestamp) RandrGetOutputInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputInfoRequest(Output, ConfigTimestamp), cookie) - return RandrGetOutputInfoCookie{cookie} -} - -func (c *Conn) RandrGetOutputInfoUnchecked(Output RandrOutput, ConfigTimestamp Timestamp) RandrGetOutputInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetOutputInfoRequest(Output, ConfigTimestamp), cookie) - return RandrGetOutputInfoCookie{cookie} -} - -// Request reply for RandrGetOutputInfo -// size: ((((36 + pad((int(NumCrtcs) * 4))) + pad((int(NumModes) * 4))) + pad((int(NumClones) * 4))) + pad((int(NameLen) * 1))) -type RandrGetOutputInfoReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - Crtc RandrCrtc - MmWidth uint32 - MmHeight uint32 - Connection byte - SubpixelOrder byte - NumCrtcs uint16 - NumModes uint16 - NumPreferred uint16 - NumClones uint16 - NameLen uint16 - Crtcs []RandrCrtc // size: pad((int(NumCrtcs) * 4)) - Modes []RandrMode // size: pad((int(NumModes) * 4)) - Clones []RandrOutput // size: pad((int(NumClones) * 4)) - Name []byte // size: pad((int(NameLen) * 1)) -} - -// Waits and reads reply data from request RandrGetOutputInfo -func (cook RandrGetOutputInfoCookie) Reply() (*RandrGetOutputInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetOutputInfoReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetOutputInfo -func randrGetOutputInfoReply(buf []byte) *RandrGetOutputInfoReply { - v := new(RandrGetOutputInfoReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Crtc = RandrCrtc(Get32(buf[b:])) - b += 4 - - v.MmWidth = Get32(buf[b:]) - b += 4 - - v.MmHeight = Get32(buf[b:]) - b += 4 - - v.Connection = buf[b] - b += 1 - - v.SubpixelOrder = buf[b] - b += 1 - - v.NumCrtcs = Get16(buf[b:]) - b += 2 - - v.NumModes = Get16(buf[b:]) - b += 2 - - v.NumPreferred = Get16(buf[b:]) - b += 2 - - v.NumClones = Get16(buf[b:]) - b += 2 - - v.NameLen = Get16(buf[b:]) - b += 2 - - v.Crtcs = make([]RandrCrtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = RandrCrtc(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]RandrMode, v.NumModes) - for i := 0; i < int(v.NumModes); i++ { - v.Modes[i] = RandrMode(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Clones = make([]RandrOutput, v.NumClones) - for i := 0; i < int(v.NumClones); i++ { - v.Clones[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Name = make([]byte, v.NameLen) - copy(v.Name[:v.NameLen], buf[b:]) - b += pad(int(v.NameLen)) - - return v -} - -func (cook RandrGetOutputInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetOutputInfo -func (c *Conn) randrGetOutputInfoRequest(Output RandrOutput, ConfigTimestamp Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - return buf -} - -// Request RandrListOutputProperties -// size: 8 -type RandrListOutputPropertiesCookie struct { - *cookie -} - -func (c *Conn) RandrListOutputProperties(Output RandrOutput) RandrListOutputPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrListOutputPropertiesRequest(Output), cookie) - return RandrListOutputPropertiesCookie{cookie} -} - -func (c *Conn) RandrListOutputPropertiesUnchecked(Output RandrOutput) RandrListOutputPropertiesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrListOutputPropertiesRequest(Output), cookie) - return RandrListOutputPropertiesCookie{cookie} -} - -// Request reply for RandrListOutputProperties -// size: (32 + pad((int(NumAtoms) * 4))) -type RandrListOutputPropertiesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAtoms uint16 - // padding: 22 bytes - Atoms []Atom // size: pad((int(NumAtoms) * 4)) -} - -// Waits and reads reply data from request RandrListOutputProperties -func (cook RandrListOutputPropertiesCookie) Reply() (*RandrListOutputPropertiesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrListOutputPropertiesReply(buf), nil -} - -// Read reply into structure from buffer for RandrListOutputProperties -func randrListOutputPropertiesReply(buf []byte) *RandrListOutputPropertiesReply { - v := new(RandrListOutputPropertiesReply) - 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.NumAtoms = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Atoms = make([]Atom, v.NumAtoms) - for i := 0; i < int(v.NumAtoms); i++ { - v.Atoms[i] = Atom(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrListOutputPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrListOutputProperties -func (c *Conn) randrListOutputPropertiesRequest(Output RandrOutput) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - return buf -} - -// Request RandrQueryOutputProperty -// size: 12 -type RandrQueryOutputPropertyCookie struct { - *cookie -} - -func (c *Conn) RandrQueryOutputProperty(Output RandrOutput, Property Atom) RandrQueryOutputPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrQueryOutputPropertyRequest(Output, Property), cookie) - return RandrQueryOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrQueryOutputPropertyUnchecked(Output RandrOutput, Property Atom) RandrQueryOutputPropertyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrQueryOutputPropertyRequest(Output, Property), cookie) - return RandrQueryOutputPropertyCookie{cookie} -} - -// Request reply for RandrQueryOutputProperty -// size: (32 + pad((int(Length) * 4))) -type RandrQueryOutputPropertyReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Pending bool - Range bool - Immutable bool - // padding: 21 bytes - ValidValues []int32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request RandrQueryOutputProperty -func (cook RandrQueryOutputPropertyCookie) Reply() (*RandrQueryOutputPropertyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrQueryOutputPropertyReply(buf), nil -} - -// Read reply into structure from buffer for RandrQueryOutputProperty -func randrQueryOutputPropertyReply(buf []byte) *RandrQueryOutputPropertyReply { - v := new(RandrQueryOutputPropertyReply) - 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.Pending = true - } else { - v.Pending = false - } - b += 1 - - if buf[b] == 1 { - v.Range = true - } else { - v.Range = false - } - b += 1 - - if buf[b] == 1 { - v.Immutable = true - } else { - v.Immutable = false - } - b += 1 - - b += 21 // padding - - v.ValidValues = make([]int32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.ValidValues[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrQueryOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrQueryOutputProperty -func (c *Conn) randrQueryOutputPropertyRequest(Output RandrOutput, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request RandrConfigureOutputProperty -// size: pad((16 + pad((len(Values) * 4)))) -type RandrConfigureOutputPropertyCookie struct { - *cookie -} - -// Write request to wire for RandrConfigureOutputProperty -func (c *Conn) RandrConfigureOutputProperty(Output RandrOutput, Property Atom, Pending bool, Range bool, Values []int32) RandrConfigureOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrConfigureOutputPropertyRequest(Output, Property, Pending, Range, Values), cookie) - return RandrConfigureOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrConfigureOutputPropertyChecked(Output RandrOutput, Property Atom, Pending bool, Range bool, Values []int32) RandrConfigureOutputPropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrConfigureOutputPropertyRequest(Output, Property, Pending, Range, Values), cookie) - return RandrConfigureOutputPropertyCookie{cookie} -} - -func (cook RandrConfigureOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrConfigureOutputProperty -func (c *Conn) randrConfigureOutputPropertyRequest(Output RandrOutput, Property Atom, Pending bool, Range bool, Values []int32) []byte { - size := pad((16 + pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Range { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - for i := 0; i < int(len(Values)); i++ { - Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RandrChangeOutputProperty -// size: pad((24 + pad((((int(NumUnits) * int(Format)) / 8) * 1)))) -type RandrChangeOutputPropertyCookie struct { - *cookie -} - -// Write request to wire for RandrChangeOutputProperty -func (c *Conn) RandrChangeOutputProperty(Output RandrOutput, Property Atom, Type Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) RandrChangeOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrChangeOutputPropertyRequest(Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return RandrChangeOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrChangeOutputPropertyChecked(Output RandrOutput, Property Atom, Type Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) RandrChangeOutputPropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrChangeOutputPropertyRequest(Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return RandrChangeOutputPropertyCookie{cookie} -} - -func (cook RandrChangeOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrChangeOutputProperty -func (c *Conn) randrChangeOutputPropertyRequest(Output RandrOutput, Property Atom, Type Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { - size := pad((24 + pad((((int(NumUnits) * int(Format)) / 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - buf[b] = Format - b += 1 - - buf[b] = Mode - b += 1 - - b += 2 // padding - - Put32(buf[b:], NumUnits) - b += 4 - - copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += pad(int(((int(NumUnits) * int(Format)) / 8))) - - return buf -} - -// Request RandrDeleteOutputProperty -// size: 12 -type RandrDeleteOutputPropertyCookie struct { - *cookie -} - -// Write request to wire for RandrDeleteOutputProperty -func (c *Conn) RandrDeleteOutputProperty(Output RandrOutput, Property Atom) RandrDeleteOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDeleteOutputPropertyRequest(Output, Property), cookie) - return RandrDeleteOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrDeleteOutputPropertyChecked(Output RandrOutput, Property Atom) RandrDeleteOutputPropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrDeleteOutputPropertyRequest(Output, Property), cookie) - return RandrDeleteOutputPropertyCookie{cookie} -} - -func (cook RandrDeleteOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrDeleteOutputProperty -func (c *Conn) randrDeleteOutputPropertyRequest(Output RandrOutput, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request RandrGetOutputProperty -// size: 28 -type RandrGetOutputPropertyCookie struct { - *cookie -} - -func (c *Conn) RandrGetOutputProperty(Output RandrOutput, Property Atom, Type Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) RandrGetOutputPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputPropertyRequest(Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return RandrGetOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrGetOutputPropertyUnchecked(Output RandrOutput, Property Atom, Type Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) RandrGetOutputPropertyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetOutputPropertyRequest(Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return RandrGetOutputPropertyCookie{cookie} -} - -// Request reply for RandrGetOutputProperty -// size: (32 + pad(((int(NumItems) * (int(Format) / 8)) * 1))) -type RandrGetOutputPropertyReply struct { - Sequence uint16 - Length uint32 - Format byte - Type Atom - BytesAfter uint32 - NumItems uint32 - // padding: 12 bytes - Data []byte // size: pad(((int(NumItems) * (int(Format) / 8)) * 1)) -} - -// Waits and reads reply data from request RandrGetOutputProperty -func (cook RandrGetOutputPropertyCookie) Reply() (*RandrGetOutputPropertyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetOutputPropertyReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetOutputProperty -func randrGetOutputPropertyReply(buf []byte) *RandrGetOutputPropertyReply { - v := new(RandrGetOutputPropertyReply) - b := 1 // skip reply determinant - - v.Format = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Type = Atom(Get32(buf[b:])) - b += 4 - - v.BytesAfter = Get32(buf[b:]) - b += 4 - - v.NumItems = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) - copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) - b += pad(int((int(v.NumItems) * (int(v.Format) / 8)))) - - return v -} - -func (cook RandrGetOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetOutputProperty -func (c *Conn) randrGetOutputPropertyRequest(Output RandrOutput, Property Atom, Type Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - Put32(buf[b:], LongOffset) - b += 4 - - Put32(buf[b:], LongLength) - b += 4 - - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - return buf -} - -// Request RandrCreateMode -// size: pad((40 + pad((len(Name) * 1)))) -type RandrCreateModeCookie struct { - *cookie -} - -func (c *Conn) RandrCreateMode(Window Window, ModeInfo RandrModeInfo, Name string) RandrCreateModeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrCreateModeRequest(Window, ModeInfo, Name), cookie) - return RandrCreateModeCookie{cookie} -} - -func (c *Conn) RandrCreateModeUnchecked(Window Window, ModeInfo RandrModeInfo, Name string) RandrCreateModeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrCreateModeRequest(Window, ModeInfo, Name), cookie) - return RandrCreateModeCookie{cookie} -} - -// Request reply for RandrCreateMode -// size: 32 -type RandrCreateModeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Mode RandrMode - // padding: 20 bytes -} - -// Waits and reads reply data from request RandrCreateMode -func (cook RandrCreateModeCookie) Reply() (*RandrCreateModeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrCreateModeReply(buf), nil -} - -// Read reply into structure from buffer for RandrCreateMode -func randrCreateModeReply(buf []byte) *RandrCreateModeReply { - v := new(RandrCreateModeReply) - 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.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook RandrCreateModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrCreateMode -func (c *Conn) randrCreateModeRequest(Window Window, ModeInfo RandrModeInfo, Name string) []byte { - size := pad((40 + pad((len(Name) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 16 // 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 - - { - structBytes := ModeInfo.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - copy(buf[b:], Name[:len(Name)]) - b += pad(int(len(Name))) - - return buf -} - -// Request RandrDestroyMode -// size: 8 -type RandrDestroyModeCookie struct { - *cookie -} - -// Write request to wire for RandrDestroyMode -func (c *Conn) RandrDestroyMode(Mode RandrMode) RandrDestroyModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDestroyModeRequest(Mode), cookie) - return RandrDestroyModeCookie{cookie} -} - -func (c *Conn) RandrDestroyModeChecked(Mode RandrMode) RandrDestroyModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrDestroyModeRequest(Mode), cookie) - return RandrDestroyModeCookie{cookie} -} - -func (cook RandrDestroyModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrDestroyMode -func (c *Conn) randrDestroyModeRequest(Mode RandrMode) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// Request RandrAddOutputMode -// size: 12 -type RandrAddOutputModeCookie struct { - *cookie -} - -// Write request to wire for RandrAddOutputMode -func (c *Conn) RandrAddOutputMode(Output RandrOutput, Mode RandrMode) RandrAddOutputModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrAddOutputModeRequest(Output, Mode), cookie) - return RandrAddOutputModeCookie{cookie} -} - -func (c *Conn) RandrAddOutputModeChecked(Output RandrOutput, Mode RandrMode) RandrAddOutputModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrAddOutputModeRequest(Output, Mode), cookie) - return RandrAddOutputModeCookie{cookie} -} - -func (cook RandrAddOutputModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrAddOutputMode -func (c *Conn) randrAddOutputModeRequest(Output RandrOutput, Mode RandrMode) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// Request RandrDeleteOutputMode -// size: 12 -type RandrDeleteOutputModeCookie struct { - *cookie -} - -// Write request to wire for RandrDeleteOutputMode -func (c *Conn) RandrDeleteOutputMode(Output RandrOutput, Mode RandrMode) RandrDeleteOutputModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDeleteOutputModeRequest(Output, Mode), cookie) - return RandrDeleteOutputModeCookie{cookie} -} - -func (c *Conn) RandrDeleteOutputModeChecked(Output RandrOutput, Mode RandrMode) RandrDeleteOutputModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrDeleteOutputModeRequest(Output, Mode), cookie) - return RandrDeleteOutputModeCookie{cookie} -} - -func (cook RandrDeleteOutputModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrDeleteOutputMode -func (c *Conn) randrDeleteOutputModeRequest(Output RandrOutput, Mode RandrMode) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// Request RandrGetCrtcInfo -// size: 12 -type RandrGetCrtcInfoCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcInfo(Crtc RandrCrtc, ConfigTimestamp Timestamp) RandrGetCrtcInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcInfoRequest(Crtc, ConfigTimestamp), cookie) - return RandrGetCrtcInfoCookie{cookie} -} - -func (c *Conn) RandrGetCrtcInfoUnchecked(Crtc RandrCrtc, ConfigTimestamp Timestamp) RandrGetCrtcInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcInfoRequest(Crtc, ConfigTimestamp), cookie) - return RandrGetCrtcInfoCookie{cookie} -} - -// Request reply for RandrGetCrtcInfo -// size: ((32 + pad((int(NumOutputs) * 4))) + pad((int(NumPossibleOutputs) * 4))) -type RandrGetCrtcInfoReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - X int16 - Y int16 - Width uint16 - Height uint16 - Mode RandrMode - Rotation uint16 - Rotations uint16 - NumOutputs uint16 - NumPossibleOutputs uint16 - Outputs []RandrOutput // size: pad((int(NumOutputs) * 4)) - Possible []RandrOutput // size: pad((int(NumPossibleOutputs) * 4)) -} - -// Waits and reads reply data from request RandrGetCrtcInfo -func (cook RandrGetCrtcInfoCookie) Reply() (*RandrGetCrtcInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcInfoReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcInfo -func randrGetCrtcInfoReply(buf []byte) *RandrGetCrtcInfoReply { - v := new(RandrGetCrtcInfoReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - v.Rotation = Get16(buf[b:]) - b += 2 - - v.Rotations = Get16(buf[b:]) - b += 2 - - v.NumOutputs = Get16(buf[b:]) - b += 2 - - v.NumPossibleOutputs = Get16(buf[b:]) - b += 2 - - v.Outputs = make([]RandrOutput, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Possible = make([]RandrOutput, v.NumPossibleOutputs) - for i := 0; i < int(v.NumPossibleOutputs); i++ { - v.Possible[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrGetCrtcInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcInfo -func (c *Conn) randrGetCrtcInfoRequest(Crtc RandrCrtc, ConfigTimestamp Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - return buf -} - -// Request RandrSetCrtcConfig -// size: pad((28 + pad((len(Outputs) * 4)))) -type RandrSetCrtcConfigCookie struct { - *cookie -} - -func (c *Conn) RandrSetCrtcConfig(Crtc RandrCrtc, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode RandrMode, Rotation uint16, Outputs []RandrOutput) RandrSetCrtcConfigCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrSetCrtcConfigRequest(Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return RandrSetCrtcConfigCookie{cookie} -} - -func (c *Conn) RandrSetCrtcConfigUnchecked(Crtc RandrCrtc, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode RandrMode, Rotation uint16, Outputs []RandrOutput) RandrSetCrtcConfigCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrSetCrtcConfigRequest(Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return RandrSetCrtcConfigCookie{cookie} -} - -// Request reply for RandrSetCrtcConfig -// size: 32 -type RandrSetCrtcConfigReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - // padding: 20 bytes -} - -// Waits and reads reply data from request RandrSetCrtcConfig -func (cook RandrSetCrtcConfigCookie) Reply() (*RandrSetCrtcConfigReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrSetCrtcConfigReply(buf), nil -} - -// Read reply into structure from buffer for RandrSetCrtcConfig -func randrSetCrtcConfigReply(buf []byte) *RandrSetCrtcConfigReply { - v := new(RandrSetCrtcConfigReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook RandrSetCrtcConfigCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetCrtcConfig -func (c *Conn) randrSetCrtcConfigRequest(Crtc RandrCrtc, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode RandrMode, Rotation uint16, Outputs []RandrOutput) []byte { - size := pad((28 + pad((len(Outputs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put32(buf[b:], uint32(Timestamp)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - Put16(buf[b:], Rotation) - b += 2 - - b += 2 // padding - - for i := 0; i < int(len(Outputs)); i++ { - Put32(buf[b:], uint32(Outputs[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RandrGetCrtcGammaSize -// size: 8 -type RandrGetCrtcGammaSizeCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcGammaSize(Crtc RandrCrtc) RandrGetCrtcGammaSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcGammaSizeRequest(Crtc), cookie) - return RandrGetCrtcGammaSizeCookie{cookie} -} - -func (c *Conn) RandrGetCrtcGammaSizeUnchecked(Crtc RandrCrtc) RandrGetCrtcGammaSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcGammaSizeRequest(Crtc), cookie) - return RandrGetCrtcGammaSizeCookie{cookie} -} - -// Request reply for RandrGetCrtcGammaSize -// size: 32 -type RandrGetCrtcGammaSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes -} - -// Waits and reads reply data from request RandrGetCrtcGammaSize -func (cook RandrGetCrtcGammaSizeCookie) Reply() (*RandrGetCrtcGammaSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcGammaSizeReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcGammaSize -func randrGetCrtcGammaSizeReply(buf []byte) *RandrGetCrtcGammaSizeReply { - v := new(RandrGetCrtcGammaSizeReply) - 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.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -func (cook RandrGetCrtcGammaSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcGammaSize -func (c *Conn) randrGetCrtcGammaSizeRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrGetCrtcGamma -// size: 8 -type RandrGetCrtcGammaCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcGamma(Crtc RandrCrtc) RandrGetCrtcGammaCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcGammaRequest(Crtc), cookie) - return RandrGetCrtcGammaCookie{cookie} -} - -func (c *Conn) RandrGetCrtcGammaUnchecked(Crtc RandrCrtc) RandrGetCrtcGammaCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcGammaRequest(Crtc), cookie) - return RandrGetCrtcGammaCookie{cookie} -} - -// Request reply for RandrGetCrtcGamma -// size: (((32 + pad((int(Size) * 2))) + pad((int(Size) * 2))) + pad((int(Size) * 2))) -type RandrGetCrtcGammaReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes - Red []uint16 // size: pad((int(Size) * 2)) - Green []uint16 // size: pad((int(Size) * 2)) - Blue []uint16 // size: pad((int(Size) * 2)) -} - -// Waits and reads reply data from request RandrGetCrtcGamma -func (cook RandrGetCrtcGammaCookie) Reply() (*RandrGetCrtcGammaReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcGammaReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcGamma -func randrGetCrtcGammaReply(buf []byte) *RandrGetCrtcGammaReply { - v := new(RandrGetCrtcGammaReply) - 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.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Red = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Red[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Green = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Green[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Blue = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Blue[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return v -} - -func (cook RandrGetCrtcGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcGamma -func (c *Conn) randrGetCrtcGammaRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrSetCrtcGamma -// size: pad((((12 + pad((int(Size) * 2))) + pad((int(Size) * 2))) + pad((int(Size) * 2)))) -type RandrSetCrtcGammaCookie struct { - *cookie -} - -// Write request to wire for RandrSetCrtcGamma -func (c *Conn) RandrSetCrtcGamma(Crtc RandrCrtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) RandrSetCrtcGammaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetCrtcGammaRequest(Crtc, Size, Red, Green, Blue), cookie) - return RandrSetCrtcGammaCookie{cookie} -} - -func (c *Conn) RandrSetCrtcGammaChecked(Crtc RandrCrtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) RandrSetCrtcGammaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetCrtcGammaRequest(Crtc, Size, Red, Green, Blue), cookie) - return RandrSetCrtcGammaCookie{cookie} -} - -func (cook RandrSetCrtcGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetCrtcGamma -func (c *Conn) randrSetCrtcGammaRequest(Crtc RandrCrtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { - size := pad((((12 + pad((int(Size) * 2))) + pad((int(Size) * 2))) + pad((int(Size) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put16(buf[b:], Size) - b += 2 - - b += 2 // padding - - for i := 0; i < int(Size); i++ { - Put16(buf[b:], Red[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(Size); i++ { - Put16(buf[b:], Green[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(Size); i++ { - Put16(buf[b:], Blue[i]) - b += 2 - } - b = pad(b) - - return buf -} - -// Request RandrGetScreenResourcesCurrent -// size: 8 -type RandrGetScreenResourcesCurrentCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenResourcesCurrent(Window Window) RandrGetScreenResourcesCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenResourcesCurrentRequest(Window), cookie) - return RandrGetScreenResourcesCurrentCookie{cookie} -} - -func (c *Conn) RandrGetScreenResourcesCurrentUnchecked(Window Window) RandrGetScreenResourcesCurrentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenResourcesCurrentRequest(Window), cookie) - return RandrGetScreenResourcesCurrentCookie{cookie} -} - -// Request reply for RandrGetScreenResourcesCurrent -// size: ((((32 + pad((int(NumCrtcs) * 4))) + pad((int(NumOutputs) * 4))) + pad((int(NumModes) * 32))) + pad((int(NamesLen) * 1))) -type RandrGetScreenResourcesCurrentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Timestamp Timestamp - ConfigTimestamp Timestamp - NumCrtcs uint16 - NumOutputs uint16 - NumModes uint16 - NamesLen uint16 - // padding: 8 bytes - Crtcs []RandrCrtc // size: pad((int(NumCrtcs) * 4)) - Outputs []RandrOutput // size: pad((int(NumOutputs) * 4)) - Modes []RandrModeInfo // size: pad((int(NumModes) * 32)) - Names []byte // size: pad((int(NamesLen) * 1)) -} - -// Waits and reads reply data from request RandrGetScreenResourcesCurrent -func (cook RandrGetScreenResourcesCurrentCookie) Reply() (*RandrGetScreenResourcesCurrentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenResourcesCurrentReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenResourcesCurrent -func randrGetScreenResourcesCurrentReply(buf []byte) *RandrGetScreenResourcesCurrentReply { - v := new(RandrGetScreenResourcesCurrentReply) - 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.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.NumCrtcs = Get16(buf[b:]) - b += 2 - - v.NumOutputs = Get16(buf[b:]) - b += 2 - - v.NumModes = Get16(buf[b:]) - b += 2 - - v.NamesLen = Get16(buf[b:]) - b += 2 - - b += 8 // padding - - v.Crtcs = make([]RandrCrtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = RandrCrtc(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Outputs = make([]RandrOutput, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]RandrModeInfo, v.NumModes) - b += ReadRandrModeInfoList(buf[b:], v.Modes) - - v.Names = make([]byte, v.NamesLen) - copy(v.Names[:v.NamesLen], buf[b:]) - b += pad(int(v.NamesLen)) - - return v -} - -func (cook RandrGetScreenResourcesCurrentCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenResourcesCurrent -func (c *Conn) randrGetScreenResourcesCurrentRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 25 // 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 RandrSetCrtcTransform -// size: pad(((48 + pad((int(FilterLen) * 1))) + pad((len(FilterParams) * 4)))) -type RandrSetCrtcTransformCookie struct { - *cookie -} - -// Write request to wire for RandrSetCrtcTransform -func (c *Conn) RandrSetCrtcTransform(Crtc RandrCrtc, Transform RenderTransform, FilterLen uint16, FilterName string, FilterParams []RenderFixed) RandrSetCrtcTransformCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetCrtcTransformRequest(Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return RandrSetCrtcTransformCookie{cookie} -} - -func (c *Conn) RandrSetCrtcTransformChecked(Crtc RandrCrtc, Transform RenderTransform, FilterLen uint16, FilterName string, FilterParams []RenderFixed) RandrSetCrtcTransformCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetCrtcTransformRequest(Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return RandrSetCrtcTransformCookie{cookie} -} - -func (cook RandrSetCrtcTransformCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetCrtcTransform -func (c *Conn) randrSetCrtcTransformRequest(Crtc RandrCrtc, Transform RenderTransform, FilterLen uint16, FilterName string, FilterParams []RenderFixed) []byte { - size := pad(((48 + pad((int(FilterLen) * 1))) + pad((len(FilterParams) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put16(buf[b:], FilterLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], FilterName[:FilterLen]) - b += pad(int(FilterLen)) - - for i := 0; i < int(len(FilterParams)); i++ { - Put32(buf[b:], uint32(FilterParams[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RandrGetCrtcTransform -// size: 8 -type RandrGetCrtcTransformCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcTransform(Crtc RandrCrtc) RandrGetCrtcTransformCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcTransformRequest(Crtc), cookie) - return RandrGetCrtcTransformCookie{cookie} -} - -func (c *Conn) RandrGetCrtcTransformUnchecked(Crtc RandrCrtc) RandrGetCrtcTransformCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcTransformRequest(Crtc), cookie) - return RandrGetCrtcTransformCookie{cookie} -} - -// Request reply for RandrGetCrtcTransform -// size: ((((96 + pad((int(PendingLen) * 1))) + pad((int(PendingNparams) * 4))) + pad((int(CurrentLen) * 1))) + pad((int(CurrentNparams) * 4))) -type RandrGetCrtcTransformReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PendingTransform RenderTransform - HasTransforms bool - // padding: 3 bytes - CurrentTransform RenderTransform - // padding: 4 bytes - PendingLen uint16 - PendingNparams uint16 - CurrentLen uint16 - CurrentNparams uint16 - PendingFilterName string // size: pad((int(PendingLen) * 1)) - PendingParams []RenderFixed // size: pad((int(PendingNparams) * 4)) - CurrentFilterName string // size: pad((int(CurrentLen) * 1)) - CurrentParams []RenderFixed // size: pad((int(CurrentNparams) * 4)) -} - -// Waits and reads reply data from request RandrGetCrtcTransform -func (cook RandrGetCrtcTransformCookie) Reply() (*RandrGetCrtcTransformReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcTransformReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcTransform -func randrGetCrtcTransformReply(buf []byte) *RandrGetCrtcTransformReply { - v := new(RandrGetCrtcTransformReply) - 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.PendingTransform = RenderTransform{} - b += ReadRenderTransform(buf[b:], &v.PendingTransform) - - if buf[b] == 1 { - v.HasTransforms = true - } else { - v.HasTransforms = false - } - b += 1 - - b += 3 // padding - - v.CurrentTransform = RenderTransform{} - b += ReadRenderTransform(buf[b:], &v.CurrentTransform) - - b += 4 // padding - - v.PendingLen = Get16(buf[b:]) - b += 2 - - v.PendingNparams = Get16(buf[b:]) - b += 2 - - v.CurrentLen = Get16(buf[b:]) - b += 2 - - v.CurrentNparams = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.PendingLen) - copy(byteString[:v.PendingLen], buf[b:]) - v.PendingFilterName = string(byteString) - b += pad(int(v.PendingLen)) - } - - v.PendingParams = make([]RenderFixed, v.PendingNparams) - for i := 0; i < int(v.PendingNparams); i++ { - v.PendingParams[i] = RenderFixed(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - { - byteString := make([]byte, v.CurrentLen) - copy(byteString[:v.CurrentLen], buf[b:]) - v.CurrentFilterName = string(byteString) - b += pad(int(v.CurrentLen)) - } - - v.CurrentParams = make([]RenderFixed, v.CurrentNparams) - for i := 0; i < int(v.CurrentNparams); i++ { - v.CurrentParams[i] = RenderFixed(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrGetCrtcTransformCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcTransform -func (c *Conn) randrGetCrtcTransformRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrGetPanning -// size: 8 -type RandrGetPanningCookie struct { - *cookie -} - -func (c *Conn) RandrGetPanning(Crtc RandrCrtc) RandrGetPanningCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetPanningRequest(Crtc), cookie) - return RandrGetPanningCookie{cookie} -} - -func (c *Conn) RandrGetPanningUnchecked(Crtc RandrCrtc) RandrGetPanningCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetPanningRequest(Crtc), cookie) - return RandrGetPanningCookie{cookie} -} - -// Request reply for RandrGetPanning -// size: 36 -type RandrGetPanningReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - Left uint16 - Top uint16 - Width uint16 - Height uint16 - TrackLeft uint16 - TrackTop uint16 - TrackWidth uint16 - TrackHeight uint16 - BorderLeft int16 - BorderTop int16 - BorderRight int16 - BorderBottom int16 -} - -// Waits and reads reply data from request RandrGetPanning -func (cook RandrGetPanningCookie) Reply() (*RandrGetPanningReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetPanningReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetPanning -func randrGetPanningReply(buf []byte) *RandrGetPanningReply { - v := new(RandrGetPanningReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Left = Get16(buf[b:]) - b += 2 - - v.Top = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.TrackLeft = Get16(buf[b:]) - b += 2 - - v.TrackTop = Get16(buf[b:]) - b += 2 - - v.TrackWidth = Get16(buf[b:]) - b += 2 - - v.TrackHeight = Get16(buf[b:]) - b += 2 - - v.BorderLeft = int16(Get16(buf[b:])) - b += 2 - - v.BorderTop = int16(Get16(buf[b:])) - b += 2 - - v.BorderRight = int16(Get16(buf[b:])) - b += 2 - - v.BorderBottom = int16(Get16(buf[b:])) - b += 2 - - return v -} - -func (cook RandrGetPanningCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetPanning -func (c *Conn) randrGetPanningRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrSetPanning -// size: 36 -type RandrSetPanningCookie struct { - *cookie -} - -func (c *Conn) RandrSetPanning(Crtc RandrCrtc, Timestamp Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) RandrSetPanningCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrSetPanningRequest(Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) - return RandrSetPanningCookie{cookie} -} - -func (c *Conn) RandrSetPanningUnchecked(Crtc RandrCrtc, Timestamp Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) RandrSetPanningCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrSetPanningRequest(Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) - return RandrSetPanningCookie{cookie} -} - -// Request reply for RandrSetPanning -// size: 12 -type RandrSetPanningReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp -} - -// Waits and reads reply data from request RandrSetPanning -func (cook RandrSetPanningCookie) Reply() (*RandrSetPanningReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrSetPanningReply(buf), nil -} - -// Read reply into structure from buffer for RandrSetPanning -func randrSetPanningReply(buf []byte) *RandrSetPanningReply { - v := new(RandrSetPanningReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook RandrSetPanningCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetPanning -func (c *Conn) randrSetPanningRequest(Crtc RandrCrtc, Timestamp Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put32(buf[b:], uint32(Timestamp)) - b += 4 - - Put16(buf[b:], Left) - b += 2 - - Put16(buf[b:], Top) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put16(buf[b:], TrackLeft) - b += 2 - - Put16(buf[b:], TrackTop) - b += 2 - - Put16(buf[b:], TrackWidth) - b += 2 - - Put16(buf[b:], TrackHeight) - b += 2 - - Put16(buf[b:], uint16(BorderLeft)) - b += 2 - - Put16(buf[b:], uint16(BorderTop)) - b += 2 - - Put16(buf[b:], uint16(BorderRight)) - b += 2 - - Put16(buf[b:], uint16(BorderBottom)) - b += 2 - - return buf -} - -// Request RandrSetOutputPrimary -// size: 12 -type RandrSetOutputPrimaryCookie struct { - *cookie -} - -// Write request to wire for RandrSetOutputPrimary -func (c *Conn) RandrSetOutputPrimary(Window Window, Output RandrOutput) RandrSetOutputPrimaryCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetOutputPrimaryRequest(Window, Output), cookie) - return RandrSetOutputPrimaryCookie{cookie} -} - -func (c *Conn) RandrSetOutputPrimaryChecked(Window Window, Output RandrOutput) RandrSetOutputPrimaryCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetOutputPrimaryRequest(Window, Output), cookie) - return RandrSetOutputPrimaryCookie{cookie} -} - -func (cook RandrSetOutputPrimaryCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetOutputPrimary -func (c *Conn) randrSetOutputPrimaryRequest(Window Window, Output RandrOutput) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 30 // 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(Output)) - b += 4 - - return buf -} - -// Request RandrGetOutputPrimary -// size: 8 -type RandrGetOutputPrimaryCookie struct { - *cookie -} - -func (c *Conn) RandrGetOutputPrimary(Window Window) RandrGetOutputPrimaryCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputPrimaryRequest(Window), cookie) - return RandrGetOutputPrimaryCookie{cookie} -} - -func (c *Conn) RandrGetOutputPrimaryUnchecked(Window Window) RandrGetOutputPrimaryCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetOutputPrimaryRequest(Window), cookie) - return RandrGetOutputPrimaryCookie{cookie} -} - -// Request reply for RandrGetOutputPrimary -// size: 12 -type RandrGetOutputPrimaryReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Output RandrOutput -} - -// Waits and reads reply data from request RandrGetOutputPrimary -func (cook RandrGetOutputPrimaryCookie) Reply() (*RandrGetOutputPrimaryReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetOutputPrimaryReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetOutputPrimary -func randrGetOutputPrimaryReply(buf []byte) *RandrGetOutputPrimaryReply { - v := new(RandrGetOutputPrimaryReply) - 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.Output = RandrOutput(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook RandrGetOutputPrimaryCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetOutputPrimary -func (c *Conn) randrGetOutputPrimaryRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 31 // 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 -} diff --git a/nexgb/auto_record.go b/nexgb/auto_record.go deleted file mode 100644 index ec936d7..0000000 --- a/nexgb/auto_record.go +++ /dev/null @@ -1,1095 +0,0 @@ -package xgb - -/* - This file was generated by record.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// RecordInit must be called before using the RECORD extension. -func (c *Conn) RecordInit() error { - reply, err := c.QueryExtension(6, "RECORD").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named RECORD could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["RECORD"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["RECORD"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["RECORD"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["RECORD"] = make(map[int]newEventFun) - newExtErrorFuncs["RECORD"] = 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 ( - RecordHTypeFromServerTime = 1 - RecordHTypeFromClientTime = 2 - RecordHTypeFromClientSequence = 4 -) - -const ( - RecordCsCurrentClients = 1 - RecordCsFutureClients = 2 - RecordCsAllClients = 3 -) - -type RecordContext uint32 - -func (c *Conn) NewRecordContextId() (RecordContext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RecordContext(id), nil -} - -type RecordElementHeader byte - -type RecordClientSpec uint32 - -// 'RecordRange8' struct definition -// Size: 2 -type RecordRange8 struct { - First byte - Last byte -} - -// Struct read RecordRange8 -func ReadRecordRange8(buf []byte, v *RecordRange8) int { - b := 0 - - v.First = buf[b] - b += 1 - - v.Last = buf[b] - b += 1 - - return b -} - -// Struct list read RecordRange8 -func ReadRecordRange8List(buf []byte, dest []RecordRange8) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordRange8{} - b += ReadRecordRange8(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordRange8 -func (v RecordRange8) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.First - b += 1 - - buf[b] = v.Last - b += 1 - - return buf -} - -// Write struct list RecordRange8 -func RecordRange8ListBytes(buf []byte, list []RecordRange8) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordRange16' struct definition -// Size: 4 -type RecordRange16 struct { - First uint16 - Last uint16 -} - -// Struct read RecordRange16 -func ReadRecordRange16(buf []byte, v *RecordRange16) int { - b := 0 - - v.First = Get16(buf[b:]) - b += 2 - - v.Last = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RecordRange16 -func ReadRecordRange16List(buf []byte, dest []RecordRange16) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordRange16{} - b += ReadRecordRange16(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordRange16 -func (v RecordRange16) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], v.First) - b += 2 - - Put16(buf[b:], v.Last) - b += 2 - - return buf -} - -// Write struct list RecordRange16 -func RecordRange16ListBytes(buf []byte, list []RecordRange16) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordExtRange' struct definition -// Size: 6 -type RecordExtRange struct { - Major RecordRange8 - Minor RecordRange16 -} - -// Struct read RecordExtRange -func ReadRecordExtRange(buf []byte, v *RecordExtRange) int { - b := 0 - - v.Major = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.Major) - - v.Minor = RecordRange16{} - b += ReadRecordRange16(buf[b:], &v.Minor) - - return b -} - -// Struct list read RecordExtRange -func ReadRecordExtRangeList(buf []byte, dest []RecordExtRange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordExtRange{} - b += ReadRecordExtRange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordExtRange -func (v RecordExtRange) Bytes() []byte { - buf := make([]byte, 6) - b := 0 - - { - structBytes := v.Major.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Minor.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RecordExtRange -func RecordExtRangeListBytes(buf []byte, list []RecordExtRange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordRange' struct definition -// Size: 24 -type RecordRange struct { - CoreRequests RecordRange8 - CoreReplies RecordRange8 - ExtRequests RecordExtRange - ExtReplies RecordExtRange - DeliveredEvents RecordRange8 - DeviceEvents RecordRange8 - Errors RecordRange8 - ClientStarted bool - ClientDied bool -} - -// Struct read RecordRange -func ReadRecordRange(buf []byte, v *RecordRange) int { - b := 0 - - v.CoreRequests = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.CoreRequests) - - v.CoreReplies = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.CoreReplies) - - v.ExtRequests = RecordExtRange{} - b += ReadRecordExtRange(buf[b:], &v.ExtRequests) - - v.ExtReplies = RecordExtRange{} - b += ReadRecordExtRange(buf[b:], &v.ExtReplies) - - v.DeliveredEvents = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.DeliveredEvents) - - v.DeviceEvents = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.DeviceEvents) - - v.Errors = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.Errors) - - if buf[b] == 1 { - v.ClientStarted = true - } else { - v.ClientStarted = false - } - b += 1 - - if buf[b] == 1 { - v.ClientDied = true - } else { - v.ClientDied = false - } - b += 1 - - return b -} - -// Struct list read RecordRange -func ReadRecordRangeList(buf []byte, dest []RecordRange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordRange{} - b += ReadRecordRange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordRange -func (v RecordRange) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.CoreRequests.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.CoreReplies.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.ExtRequests.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.ExtReplies.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.DeliveredEvents.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.DeviceEvents.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Errors.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - if v.ClientStarted { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if v.ClientDied { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Write struct list RecordRange -func RecordRangeListBytes(buf []byte, list []RecordRange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordClientInfo' struct definition -// Size: (8 + pad((int(NumRanges) * 24))) -type RecordClientInfo struct { - ClientResource RecordClientSpec - NumRanges uint32 - Ranges []RecordRange // size: pad((int(NumRanges) * 24)) -} - -// Struct read RecordClientInfo -func ReadRecordClientInfo(buf []byte, v *RecordClientInfo) int { - b := 0 - - v.ClientResource = RecordClientSpec(Get32(buf[b:])) - b += 4 - - v.NumRanges = Get32(buf[b:]) - b += 4 - - v.Ranges = make([]RecordRange, v.NumRanges) - b += ReadRecordRangeList(buf[b:], v.Ranges) - - return b -} - -// Struct list read RecordClientInfo -func ReadRecordClientInfoList(buf []byte, dest []RecordClientInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordClientInfo{} - b += ReadRecordClientInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordClientInfo -func (v RecordClientInfo) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumRanges) * 24)))) - b := 0 - - Put32(buf[b:], uint32(v.ClientResource)) - b += 4 - - Put32(buf[b:], v.NumRanges) - b += 4 - - b += RecordRangeListBytes(buf[b:], v.Ranges) - - return buf -} - -// Write struct list RecordClientInfo -func RecordClientInfoListBytes(buf []byte, list []RecordClientInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RecordClientInfo -func RecordClientInfoListSize(list []RecordClientInfo) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumRanges) * 24))) - } - return size -} - -// Error definition RecordBadContext (0) -// Size: 32 - -const BadRecordBadContext = 0 - -type RecordBadContextError struct { - Sequence uint16 - NiceName string - InvalidRecord uint32 -} - -// Error read RecordBadContext -func NewRecordBadContextError(buf []byte) Error { - v := RecordBadContextError{} - v.NiceName = "RecordBadContext" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.InvalidRecord = Get32(buf[b:]) - b += 4 - - return v -} - -func (err RecordBadContextError) ImplementsError() {} - -func (err RecordBadContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err RecordBadContextError) BadId() uint32 { - return 0 -} - -func (err RecordBadContextError) Error() string { - fieldVals := make([]string, 0, 1) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("InvalidRecord: %d", err.InvalidRecord)) - return "BadRecordBadContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RECORD"][0] = NewRecordBadContextError -} - -// Request RecordQueryVersion -// size: 8 -type RecordQueryVersionCookie struct { - *cookie -} - -func (c *Conn) RecordQueryVersion(MajorVersion uint16, MinorVersion uint16) RecordQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.recordQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RecordQueryVersionCookie{cookie} -} - -func (c *Conn) RecordQueryVersionUnchecked(MajorVersion uint16, MinorVersion uint16) RecordQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.recordQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RecordQueryVersionCookie{cookie} -} - -// Request reply for RecordQueryVersion -// size: 12 -type RecordQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request RecordQueryVersion -func (cook RecordQueryVersionCookie) Reply() (*RecordQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return recordQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for RecordQueryVersion -func recordQueryVersionReply(buf []byte) *RecordQueryVersionReply { - v := new(RecordQueryVersionReply) - 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 RecordQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordQueryVersion -func (c *Conn) recordQueryVersionRequest(MajorVersion uint16, MinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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:], MajorVersion) - b += 2 - - Put16(buf[b:], MinorVersion) - b += 2 - - return buf -} - -// Request RecordCreateContext -// size: pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) -type RecordCreateContextCookie struct { - *cookie -} - -// Write request to wire for RecordCreateContext -func (c *Conn) RecordCreateContext(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordCreateContextRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordCreateContextCookie{cookie} -} - -func (c *Conn) RecordCreateContextChecked(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordCreateContextRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordCreateContextCookie{cookie} -} - -func (cook RecordCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordCreateContext -func (c *Conn) recordCreateContextRequest(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) []byte { - size := pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - buf[b] = byte(ElementHeader) - b += 1 - - b += 3 // padding - - Put32(buf[b:], NumClientSpecs) - b += 4 - - Put32(buf[b:], NumRanges) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = pad(b) - - b += RecordRangeListBytes(buf[b:], Ranges) - - return buf -} - -// Request RecordRegisterClients -// size: pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) -type RecordRegisterClientsCookie struct { - *cookie -} - -// Write request to wire for RecordRegisterClients -func (c *Conn) RecordRegisterClients(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordRegisterClientsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordRegisterClientsRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordRegisterClientsCookie{cookie} -} - -func (c *Conn) RecordRegisterClientsChecked(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordRegisterClientsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordRegisterClientsRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordRegisterClientsCookie{cookie} -} - -func (cook RecordRegisterClientsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordRegisterClients -func (c *Conn) recordRegisterClientsRequest(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) []byte { - size := pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - buf[b] = byte(ElementHeader) - b += 1 - - b += 3 // padding - - Put32(buf[b:], NumClientSpecs) - b += 4 - - Put32(buf[b:], NumRanges) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = pad(b) - - b += RecordRangeListBytes(buf[b:], Ranges) - - return buf -} - -// Request RecordUnregisterClients -// size: pad((12 + pad((int(NumClientSpecs) * 4)))) -type RecordUnregisterClientsCookie struct { - *cookie -} - -// Write request to wire for RecordUnregisterClients -func (c *Conn) RecordUnregisterClients(Context RecordContext, NumClientSpecs uint32, ClientSpecs []RecordClientSpec) RecordUnregisterClientsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordUnregisterClientsRequest(Context, NumClientSpecs, ClientSpecs), cookie) - return RecordUnregisterClientsCookie{cookie} -} - -func (c *Conn) RecordUnregisterClientsChecked(Context RecordContext, NumClientSpecs uint32, ClientSpecs []RecordClientSpec) RecordUnregisterClientsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordUnregisterClientsRequest(Context, NumClientSpecs, ClientSpecs), cookie) - return RecordUnregisterClientsCookie{cookie} -} - -func (cook RecordUnregisterClientsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordUnregisterClients -func (c *Conn) recordUnregisterClientsRequest(Context RecordContext, NumClientSpecs uint32, ClientSpecs []RecordClientSpec) []byte { - size := pad((12 + pad((int(NumClientSpecs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - Put32(buf[b:], NumClientSpecs) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RecordGetContext -// size: 8 -type RecordGetContextCookie struct { - *cookie -} - -func (c *Conn) RecordGetContext(Context RecordContext) RecordGetContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.recordGetContextRequest(Context), cookie) - return RecordGetContextCookie{cookie} -} - -func (c *Conn) RecordGetContextUnchecked(Context RecordContext) RecordGetContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.recordGetContextRequest(Context), cookie) - return RecordGetContextCookie{cookie} -} - -// Request reply for RecordGetContext -// size: (32 + RecordClientInfoListSize(InterceptedClients)) -type RecordGetContextReply struct { - Sequence uint16 - Length uint32 - Enabled bool - ElementHeader RecordElementHeader - // padding: 3 bytes - NumInterceptedClients uint32 - // padding: 16 bytes - InterceptedClients []RecordClientInfo // size: RecordClientInfoListSize(InterceptedClients) -} - -// Waits and reads reply data from request RecordGetContext -func (cook RecordGetContextCookie) Reply() (*RecordGetContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return recordGetContextReply(buf), nil -} - -// Read reply into structure from buffer for RecordGetContext -func recordGetContextReply(buf []byte) *RecordGetContextReply { - v := new(RecordGetContextReply) - 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 - - v.ElementHeader = RecordElementHeader(buf[b]) - b += 1 - - b += 3 // padding - - v.NumInterceptedClients = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.InterceptedClients = make([]RecordClientInfo, v.NumInterceptedClients) - b += ReadRecordClientInfoList(buf[b:], v.InterceptedClients) - - return v -} - -func (cook RecordGetContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordGetContext -func (c *Conn) recordGetContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - return buf -} - -// Request RecordEnableContext -// size: 8 -type RecordEnableContextCookie struct { - *cookie -} - -func (c *Conn) RecordEnableContext(Context RecordContext) RecordEnableContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.recordEnableContextRequest(Context), cookie) - return RecordEnableContextCookie{cookie} -} - -func (c *Conn) RecordEnableContextUnchecked(Context RecordContext) RecordEnableContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.recordEnableContextRequest(Context), cookie) - return RecordEnableContextCookie{cookie} -} - -// Request reply for RecordEnableContext -// size: (32 + pad(((int(Length) * 4) * 1))) -type RecordEnableContextReply struct { - Sequence uint16 - Length uint32 - Category byte - ElementHeader RecordElementHeader - ClientSwapped bool - // padding: 2 bytes - XidBase uint32 - ServerTime uint32 - RecSequenceNum uint32 - // padding: 8 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request RecordEnableContext -func (cook RecordEnableContextCookie) Reply() (*RecordEnableContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return recordEnableContextReply(buf), nil -} - -// Read reply into structure from buffer for RecordEnableContext -func recordEnableContextReply(buf []byte) *RecordEnableContextReply { - v := new(RecordEnableContextReply) - b := 1 // skip reply determinant - - v.Category = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ElementHeader = RecordElementHeader(buf[b]) - b += 1 - - if buf[b] == 1 { - v.ClientSwapped = true - } else { - v.ClientSwapped = false - } - b += 1 - - b += 2 // padding - - v.XidBase = Get32(buf[b:]) - b += 4 - - v.ServerTime = Get32(buf[b:]) - b += 4 - - v.RecSequenceNum = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook RecordEnableContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordEnableContext -func (c *Conn) recordEnableContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - return buf -} - -// Request RecordDisableContext -// size: 8 -type RecordDisableContextCookie struct { - *cookie -} - -// Write request to wire for RecordDisableContext -func (c *Conn) RecordDisableContext(Context RecordContext) RecordDisableContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordDisableContextRequest(Context), cookie) - return RecordDisableContextCookie{cookie} -} - -func (c *Conn) RecordDisableContextChecked(Context RecordContext) RecordDisableContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordDisableContextRequest(Context), cookie) - return RecordDisableContextCookie{cookie} -} - -func (cook RecordDisableContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordDisableContext -func (c *Conn) recordDisableContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - return buf -} - -// Request RecordFreeContext -// size: 8 -type RecordFreeContextCookie struct { - *cookie -} - -// Write request to wire for RecordFreeContext -func (c *Conn) RecordFreeContext(Context RecordContext) RecordFreeContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordFreeContextRequest(Context), cookie) - return RecordFreeContextCookie{cookie} -} - -func (c *Conn) RecordFreeContextChecked(Context RecordContext) RecordFreeContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordFreeContextRequest(Context), cookie) - return RecordFreeContextCookie{cookie} -} - -func (cook RecordFreeContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordFreeContext -func (c *Conn) recordFreeContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - 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(Context)) - b += 4 - - return buf -} diff --git a/nexgb/auto_render.go b/nexgb/auto_render.go deleted file mode 100644 index 5e1ff12..0000000 --- a/nexgb/auto_render.go +++ /dev/null @@ -1,3556 +0,0 @@ -package xgb - -/* - This file was generated by render.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" - -// RenderInit must be called before using the RENDER extension. -func (c *Conn) RenderInit() error { - reply, err := c.QueryExtension(6, "RENDER").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named RENDER could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["RENDER"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["RENDER"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["RENDER"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["RENDER"] = make(map[int]newEventFun) - newExtErrorFuncs["RENDER"] = 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 ( - RenderPictTypeIndexed = 0 - RenderPictTypeDirect = 1 -) - -const ( - RenderPictureNone = 0 -) - -const ( - RenderPictOpClear = 0 - RenderPictOpSrc = 1 - RenderPictOpDst = 2 - RenderPictOpOver = 3 - RenderPictOpOverReverse = 4 - RenderPictOpIn = 5 - RenderPictOpInReverse = 6 - RenderPictOpOut = 7 - RenderPictOpOutReverse = 8 - RenderPictOpAtop = 9 - RenderPictOpAtopReverse = 10 - RenderPictOpXor = 11 - RenderPictOpAdd = 12 - RenderPictOpSaturate = 13 - RenderPictOpDisjointClear = 16 - RenderPictOpDisjointSrc = 17 - RenderPictOpDisjointDst = 18 - RenderPictOpDisjointOver = 19 - RenderPictOpDisjointOverReverse = 20 - RenderPictOpDisjointIn = 21 - RenderPictOpDisjointInReverse = 22 - RenderPictOpDisjointOut = 23 - RenderPictOpDisjointOutReverse = 24 - RenderPictOpDisjointAtop = 25 - RenderPictOpDisjointAtopReverse = 26 - RenderPictOpDisjointXor = 27 - RenderPictOpConjointClear = 32 - RenderPictOpConjointSrc = 33 - RenderPictOpConjointDst = 34 - RenderPictOpConjointOver = 35 - RenderPictOpConjointOverReverse = 36 - RenderPictOpConjointIn = 37 - RenderPictOpConjointInReverse = 38 - RenderPictOpConjointOut = 39 - RenderPictOpConjointOutReverse = 40 - RenderPictOpConjointAtop = 41 - RenderPictOpConjointAtopReverse = 42 - RenderPictOpConjointXor = 43 - RenderPictOpMultiply = 48 - RenderPictOpScreen = 49 - RenderPictOpOverlay = 50 - RenderPictOpDarken = 51 - RenderPictOpLighten = 52 - RenderPictOpColorDodge = 53 - RenderPictOpColorBurn = 54 - RenderPictOpHardLight = 55 - RenderPictOpSoftLight = 56 - RenderPictOpDifference = 57 - RenderPictOpExclusion = 58 - RenderPictOpHSLHue = 59 - RenderPictOpHSLSaturation = 60 - RenderPictOpHSLColor = 61 - RenderPictOpHSLLuminosity = 62 -) - -const ( - RenderPolyEdgeSharp = 0 - RenderPolyEdgeSmooth = 1 -) - -const ( - RenderPolyModePrecise = 0 - RenderPolyModeImprecise = 1 -) - -const ( - RenderCpRepeat = 1 - RenderCpAlphaMap = 2 - RenderCpAlphaXOrigin = 4 - RenderCpAlphaYOrigin = 8 - RenderCpClipXOrigin = 16 - RenderCpClipYOrigin = 32 - RenderCpClipMask = 64 - RenderCpGraphicsExposure = 128 - RenderCpSubwindowMode = 256 - RenderCpPolyEdge = 512 - RenderCpPolyMode = 1024 - RenderCpDither = 2048 - RenderCpComponentAlpha = 4096 -) - -const ( - RenderSubPixelUnknown = 0 - RenderSubPixelHorizontalRGB = 1 - RenderSubPixelHorizontalBGR = 2 - RenderSubPixelVerticalRGB = 3 - RenderSubPixelVerticalBGR = 4 - RenderSubPixelNone = 5 -) - -const ( - RenderRepeatNone = 0 - RenderRepeatNormal = 1 - RenderRepeatPad = 2 - RenderRepeatReflect = 3 -) - -type RenderGlyphset uint32 - -func (c *Conn) NewRenderGlyphsetId() (RenderGlyphset, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RenderGlyphset(id), nil -} - -type RenderPicture uint32 - -func (c *Conn) NewRenderPictureId() (RenderPicture, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RenderPicture(id), nil -} - -type RenderPictformat uint32 - -func (c *Conn) NewRenderPictformatId() (RenderPictformat, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RenderPictformat(id), nil -} - -type RenderGlyph uint32 - -type RenderFixed int32 - -// 'RenderDirectformat' struct definition -// Size: 16 -type RenderDirectformat struct { - RedShift uint16 - RedMask uint16 - GreenShift uint16 - GreenMask uint16 - BlueShift uint16 - BlueMask uint16 - AlphaShift uint16 - AlphaMask uint16 -} - -// Struct read RenderDirectformat -func ReadRenderDirectformat(buf []byte, v *RenderDirectformat) int { - b := 0 - - v.RedShift = Get16(buf[b:]) - b += 2 - - v.RedMask = Get16(buf[b:]) - b += 2 - - v.GreenShift = Get16(buf[b:]) - b += 2 - - v.GreenMask = Get16(buf[b:]) - b += 2 - - v.BlueShift = Get16(buf[b:]) - b += 2 - - v.BlueMask = Get16(buf[b:]) - b += 2 - - v.AlphaShift = Get16(buf[b:]) - b += 2 - - v.AlphaMask = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RenderDirectformat -func ReadRenderDirectformatList(buf []byte, dest []RenderDirectformat) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderDirectformat{} - b += ReadRenderDirectformat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderDirectformat -func (v RenderDirectformat) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - Put16(buf[b:], v.RedShift) - b += 2 - - Put16(buf[b:], v.RedMask) - b += 2 - - Put16(buf[b:], v.GreenShift) - b += 2 - - Put16(buf[b:], v.GreenMask) - b += 2 - - Put16(buf[b:], v.BlueShift) - b += 2 - - Put16(buf[b:], v.BlueMask) - b += 2 - - Put16(buf[b:], v.AlphaShift) - b += 2 - - Put16(buf[b:], v.AlphaMask) - b += 2 - - return buf -} - -// Write struct list RenderDirectformat -func RenderDirectformatListBytes(buf []byte, list []RenderDirectformat) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPictforminfo' struct definition -// Size: 28 -type RenderPictforminfo struct { - Id RenderPictformat - Type byte - Depth byte - // padding: 2 bytes - Direct RenderDirectformat - Colormap Colormap -} - -// Struct read RenderPictforminfo -func ReadRenderPictforminfo(buf []byte, v *RenderPictforminfo) int { - b := 0 - - v.Id = RenderPictformat(Get32(buf[b:])) - b += 4 - - v.Type = buf[b] - b += 1 - - v.Depth = buf[b] - b += 1 - - b += 2 // padding - - v.Direct = RenderDirectformat{} - b += ReadRenderDirectformat(buf[b:], &v.Direct) - - v.Colormap = Colormap(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderPictforminfo -func ReadRenderPictforminfoList(buf []byte, dest []RenderPictforminfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictforminfo{} - b += ReadRenderPictforminfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictforminfo -func (v RenderPictforminfo) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Id)) - b += 4 - - buf[b] = v.Type - b += 1 - - buf[b] = v.Depth - b += 1 - - b += 2 // padding - - { - structBytes := v.Direct.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(v.Colormap)) - b += 4 - - return buf -} - -// Write struct list RenderPictforminfo -func RenderPictforminfoListBytes(buf []byte, list []RenderPictforminfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPictvisual' struct definition -// Size: 8 -type RenderPictvisual struct { - Visual Visualid - Format RenderPictformat -} - -// Struct read RenderPictvisual -func ReadRenderPictvisual(buf []byte, v *RenderPictvisual) int { - b := 0 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Format = RenderPictformat(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderPictvisual -func ReadRenderPictvisualList(buf []byte, dest []RenderPictvisual) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictvisual{} - b += ReadRenderPictvisual(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictvisual -func (v RenderPictvisual) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Visual)) - b += 4 - - Put32(buf[b:], uint32(v.Format)) - b += 4 - - return buf -} - -// Write struct list RenderPictvisual -func RenderPictvisualListBytes(buf []byte, list []RenderPictvisual) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPictdepth' struct definition -// Size: (8 + pad((int(NumVisuals) * 8))) -type RenderPictdepth struct { - Depth byte - // padding: 1 bytes - NumVisuals uint16 - // padding: 4 bytes - Visuals []RenderPictvisual // size: pad((int(NumVisuals) * 8)) -} - -// Struct read RenderPictdepth -func ReadRenderPictdepth(buf []byte, v *RenderPictdepth) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - b += 1 // padding - - v.NumVisuals = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Visuals = make([]RenderPictvisual, v.NumVisuals) - b += ReadRenderPictvisualList(buf[b:], v.Visuals) - - return b -} - -// Struct list read RenderPictdepth -func ReadRenderPictdepthList(buf []byte, dest []RenderPictdepth) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictdepth{} - b += ReadRenderPictdepth(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictdepth -func (v RenderPictdepth) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumVisuals) * 8)))) - b := 0 - - buf[b] = v.Depth - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.NumVisuals) - b += 2 - - b += 4 // padding - - b += RenderPictvisualListBytes(buf[b:], v.Visuals) - - return buf -} - -// Write struct list RenderPictdepth -func RenderPictdepthListBytes(buf []byte, list []RenderPictdepth) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RenderPictdepth -func RenderPictdepthListSize(list []RenderPictdepth) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumVisuals) * 8))) - } - return size -} - -// 'RenderPictscreen' struct definition -// Size: (8 + RenderPictdepthListSize(Depths)) -type RenderPictscreen struct { - NumDepths uint32 - Fallback RenderPictformat - Depths []RenderPictdepth // size: RenderPictdepthListSize(Depths) -} - -// Struct read RenderPictscreen -func ReadRenderPictscreen(buf []byte, v *RenderPictscreen) int { - b := 0 - - v.NumDepths = Get32(buf[b:]) - b += 4 - - v.Fallback = RenderPictformat(Get32(buf[b:])) - b += 4 - - v.Depths = make([]RenderPictdepth, v.NumDepths) - b += ReadRenderPictdepthList(buf[b:], v.Depths) - - return b -} - -// Struct list read RenderPictscreen -func ReadRenderPictscreenList(buf []byte, dest []RenderPictscreen) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictscreen{} - b += ReadRenderPictscreen(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictscreen -func (v RenderPictscreen) Bytes() []byte { - buf := make([]byte, (8 + RenderPictdepthListSize(v.Depths))) - b := 0 - - Put32(buf[b:], v.NumDepths) - b += 4 - - Put32(buf[b:], uint32(v.Fallback)) - b += 4 - - b += RenderPictdepthListBytes(buf[b:], v.Depths) - - return buf -} - -// Write struct list RenderPictscreen -func RenderPictscreenListBytes(buf []byte, list []RenderPictscreen) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RenderPictscreen -func RenderPictscreenListSize(list []RenderPictscreen) int { - size := 0 - for _, item := range list { - size += (8 + RenderPictdepthListSize(item.Depths)) - } - return size -} - -// 'RenderIndexvalue' struct definition -// Size: 12 -type RenderIndexvalue struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} - -// Struct read RenderIndexvalue -func ReadRenderIndexvalue(buf []byte, v *RenderIndexvalue) int { - b := 0 - - v.Pixel = Get32(buf[b:]) - b += 4 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - v.Alpha = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RenderIndexvalue -func ReadRenderIndexvalueList(buf []byte, dest []RenderIndexvalue) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderIndexvalue{} - b += ReadRenderIndexvalue(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderIndexvalue -func (v RenderIndexvalue) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], v.Pixel) - b += 4 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - Put16(buf[b:], v.Alpha) - b += 2 - - return buf -} - -// Write struct list RenderIndexvalue -func RenderIndexvalueListBytes(buf []byte, list []RenderIndexvalue) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderColor' struct definition -// Size: 8 -type RenderColor struct { - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} - -// Struct read RenderColor -func ReadRenderColor(buf []byte, v *RenderColor) int { - b := 0 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - v.Alpha = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RenderColor -func ReadRenderColorList(buf []byte, dest []RenderColor) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderColor{} - b += ReadRenderColor(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderColor -func (v RenderColor) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - Put16(buf[b:], v.Alpha) - b += 2 - - return buf -} - -// Write struct list RenderColor -func RenderColorListBytes(buf []byte, list []RenderColor) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPointfix' struct definition -// Size: 8 -type RenderPointfix struct { - X RenderFixed - Y RenderFixed -} - -// Struct read RenderPointfix -func ReadRenderPointfix(buf []byte, v *RenderPointfix) int { - b := 0 - - v.X = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Y = RenderFixed(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderPointfix -func ReadRenderPointfixList(buf []byte, dest []RenderPointfix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPointfix -func (v RenderPointfix) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.X)) - b += 4 - - Put32(buf[b:], uint32(v.Y)) - b += 4 - - return buf -} - -// Write struct list RenderPointfix -func RenderPointfixListBytes(buf []byte, list []RenderPointfix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderLinefix' struct definition -// Size: 16 -type RenderLinefix struct { - P1 RenderPointfix - P2 RenderPointfix -} - -// Struct read RenderLinefix -func ReadRenderLinefix(buf []byte, v *RenderLinefix) int { - b := 0 - - v.P1 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P1) - - v.P2 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P2) - - return b -} - -// Struct list read RenderLinefix -func ReadRenderLinefixList(buf []byte, dest []RenderLinefix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderLinefix{} - b += ReadRenderLinefix(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderLinefix -func (v RenderLinefix) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderLinefix -func RenderLinefixListBytes(buf []byte, list []RenderLinefix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTriangle' struct definition -// Size: 24 -type RenderTriangle struct { - P1 RenderPointfix - P2 RenderPointfix - P3 RenderPointfix -} - -// Struct read RenderTriangle -func ReadRenderTriangle(buf []byte, v *RenderTriangle) int { - b := 0 - - v.P1 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P1) - - v.P2 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P2) - - v.P3 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P3) - - return b -} - -// Struct list read RenderTriangle -func ReadRenderTriangleList(buf []byte, dest []RenderTriangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTriangle{} - b += ReadRenderTriangle(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTriangle -func (v RenderTriangle) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.P3.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderTriangle -func RenderTriangleListBytes(buf []byte, list []RenderTriangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTrapezoid' struct definition -// Size: 40 -type RenderTrapezoid struct { - Top RenderFixed - Bottom RenderFixed - Left RenderLinefix - Right RenderLinefix -} - -// Struct read RenderTrapezoid -func ReadRenderTrapezoid(buf []byte, v *RenderTrapezoid) int { - b := 0 - - v.Top = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Bottom = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Left = RenderLinefix{} - b += ReadRenderLinefix(buf[b:], &v.Left) - - v.Right = RenderLinefix{} - b += ReadRenderLinefix(buf[b:], &v.Right) - - return b -} - -// Struct list read RenderTrapezoid -func ReadRenderTrapezoidList(buf []byte, dest []RenderTrapezoid) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTrapezoid{} - b += ReadRenderTrapezoid(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTrapezoid -func (v RenderTrapezoid) Bytes() []byte { - buf := make([]byte, 40) - b := 0 - - Put32(buf[b:], uint32(v.Top)) - b += 4 - - Put32(buf[b:], uint32(v.Bottom)) - b += 4 - - { - structBytes := v.Left.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Right.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderTrapezoid -func RenderTrapezoidListBytes(buf []byte, list []RenderTrapezoid) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderGlyphinfo' struct definition -// Size: 12 -type RenderGlyphinfo struct { - Width uint16 - Height uint16 - X int16 - Y int16 - XOff int16 - YOff int16 -} - -// Struct read RenderGlyphinfo -func ReadRenderGlyphinfo(buf []byte, v *RenderGlyphinfo) int { - b := 0 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.XOff = int16(Get16(buf[b:])) - b += 2 - - v.YOff = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read RenderGlyphinfo -func ReadRenderGlyphinfoList(buf []byte, dest []RenderGlyphinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderGlyphinfo{} - b += ReadRenderGlyphinfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderGlyphinfo -func (v RenderGlyphinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], uint16(v.XOff)) - b += 2 - - Put16(buf[b:], uint16(v.YOff)) - b += 2 - - return buf -} - -// Write struct list RenderGlyphinfo -func RenderGlyphinfoListBytes(buf []byte, list []RenderGlyphinfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTransform' struct definition -// Size: 36 -type RenderTransform struct { - Matrix11 RenderFixed - Matrix12 RenderFixed - Matrix13 RenderFixed - Matrix21 RenderFixed - Matrix22 RenderFixed - Matrix23 RenderFixed - Matrix31 RenderFixed - Matrix32 RenderFixed - Matrix33 RenderFixed -} - -// Struct read RenderTransform -func ReadRenderTransform(buf []byte, v *RenderTransform) int { - b := 0 - - v.Matrix11 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix12 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix13 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix21 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix22 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix23 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix31 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix32 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix33 = RenderFixed(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderTransform -func ReadRenderTransformList(buf []byte, dest []RenderTransform) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTransform{} - b += ReadRenderTransform(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTransform -func (v RenderTransform) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - Put32(buf[b:], uint32(v.Matrix11)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix12)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix13)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix21)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix22)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix23)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix31)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix32)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix33)) - b += 4 - - return buf -} - -// Write struct list RenderTransform -func RenderTransformListBytes(buf []byte, list []RenderTransform) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderAnimcursorelt' struct definition -// Size: 8 -type RenderAnimcursorelt struct { - Cursor Cursor - Delay uint32 -} - -// Struct read RenderAnimcursorelt -func ReadRenderAnimcursorelt(buf []byte, v *RenderAnimcursorelt) int { - b := 0 - - v.Cursor = Cursor(Get32(buf[b:])) - b += 4 - - v.Delay = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read RenderAnimcursorelt -func ReadRenderAnimcursoreltList(buf []byte, dest []RenderAnimcursorelt) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderAnimcursorelt{} - b += ReadRenderAnimcursorelt(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderAnimcursorelt -func (v RenderAnimcursorelt) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Cursor)) - b += 4 - - Put32(buf[b:], v.Delay) - b += 4 - - return buf -} - -// Write struct list RenderAnimcursorelt -func RenderAnimcursoreltListBytes(buf []byte, list []RenderAnimcursorelt) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderSpanfix' struct definition -// Size: 12 -type RenderSpanfix struct { - L RenderFixed - R RenderFixed - Y RenderFixed -} - -// Struct read RenderSpanfix -func ReadRenderSpanfix(buf []byte, v *RenderSpanfix) int { - b := 0 - - v.L = RenderFixed(Get32(buf[b:])) - b += 4 - - v.R = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Y = RenderFixed(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderSpanfix -func ReadRenderSpanfixList(buf []byte, dest []RenderSpanfix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderSpanfix{} - b += ReadRenderSpanfix(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderSpanfix -func (v RenderSpanfix) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], uint32(v.L)) - b += 4 - - Put32(buf[b:], uint32(v.R)) - b += 4 - - Put32(buf[b:], uint32(v.Y)) - b += 4 - - return buf -} - -// Write struct list RenderSpanfix -func RenderSpanfixListBytes(buf []byte, list []RenderSpanfix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTrap' struct definition -// Size: 24 -type RenderTrap struct { - Top RenderSpanfix - Bot RenderSpanfix -} - -// Struct read RenderTrap -func ReadRenderTrap(buf []byte, v *RenderTrap) int { - b := 0 - - v.Top = RenderSpanfix{} - b += ReadRenderSpanfix(buf[b:], &v.Top) - - v.Bot = RenderSpanfix{} - b += ReadRenderSpanfix(buf[b:], &v.Bot) - - return b -} - -// Struct list read RenderTrap -func ReadRenderTrapList(buf []byte, dest []RenderTrap) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTrap{} - b += ReadRenderTrap(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTrap -func (v RenderTrap) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.Top.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Bot.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderTrap -func RenderTrapListBytes(buf []byte, list []RenderTrap) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Error definition RenderPictFormat (0) -// Size: 32 - -const BadRenderPictFormat = 0 - -type RenderPictFormatError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderPictFormat -func NewRenderPictFormatError(buf []byte) Error { - v := RenderPictFormatError{} - v.NiceName = "RenderPictFormat" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderPictFormatError) ImplementsError() {} - -func (err RenderPictFormatError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderPictFormatError) BadId() uint32 { - return 0 -} - -func (err RenderPictFormatError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderPictFormat {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][0] = NewRenderPictFormatError -} - -// Error definition RenderPicture (1) -// Size: 32 - -const BadRenderPicture = 1 - -type RenderPictureError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderPicture -func NewRenderPictureError(buf []byte) Error { - v := RenderPictureError{} - v.NiceName = "RenderPicture" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderPictureError) ImplementsError() {} - -func (err RenderPictureError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderPictureError) BadId() uint32 { - return 0 -} - -func (err RenderPictureError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderPicture {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][1] = NewRenderPictureError -} - -// Error definition RenderPictOp (2) -// Size: 32 - -const BadRenderPictOp = 2 - -type RenderPictOpError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderPictOp -func NewRenderPictOpError(buf []byte) Error { - v := RenderPictOpError{} - v.NiceName = "RenderPictOp" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderPictOpError) ImplementsError() {} - -func (err RenderPictOpError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderPictOpError) BadId() uint32 { - return 0 -} - -func (err RenderPictOpError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderPictOp {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][2] = NewRenderPictOpError -} - -// Error definition RenderGlyphSet (3) -// Size: 32 - -const BadRenderGlyphSet = 3 - -type RenderGlyphSetError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderGlyphSet -func NewRenderGlyphSetError(buf []byte) Error { - v := RenderGlyphSetError{} - v.NiceName = "RenderGlyphSet" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderGlyphSetError) ImplementsError() {} - -func (err RenderGlyphSetError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderGlyphSetError) BadId() uint32 { - return 0 -} - -func (err RenderGlyphSetError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderGlyphSet {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][3] = NewRenderGlyphSetError -} - -// Error definition RenderGlyph (4) -// Size: 32 - -const BadRenderGlyph = 4 - -type RenderGlyphError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderGlyph -func NewRenderGlyphError(buf []byte) Error { - v := RenderGlyphError{} - v.NiceName = "RenderGlyph" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderGlyphError) ImplementsError() {} - -func (err RenderGlyphError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderGlyphError) BadId() uint32 { - return 0 -} - -func (err RenderGlyphError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderGlyph {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][4] = NewRenderGlyphError -} - -// Request RenderQueryVersion -// size: 12 -type RenderQueryVersionCookie struct { - *cookie -} - -func (c *Conn) RenderQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) RenderQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return RenderQueryVersionCookie{cookie} -} - -func (c *Conn) RenderQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) RenderQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return RenderQueryVersionCookie{cookie} -} - -// Request reply for RenderQueryVersion -// size: 32 -type RenderQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request RenderQueryVersion -func (cook RenderQueryVersionCookie) Reply() (*RenderQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryVersion -func renderQueryVersionReply(buf []byte) *RenderQueryVersionReply { - v := new(RenderQueryVersionReply) - 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 RenderQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryVersion -func (c *Conn) renderQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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 RenderQueryPictFormats -// size: 4 -type RenderQueryPictFormatsCookie struct { - *cookie -} - -func (c *Conn) RenderQueryPictFormats() RenderQueryPictFormatsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryPictFormatsRequest(), cookie) - return RenderQueryPictFormatsCookie{cookie} -} - -func (c *Conn) RenderQueryPictFormatsUnchecked() RenderQueryPictFormatsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryPictFormatsRequest(), cookie) - return RenderQueryPictFormatsCookie{cookie} -} - -// Request reply for RenderQueryPictFormats -// size: (((32 + pad((int(NumFormats) * 28))) + RenderPictscreenListSize(Screens)) + pad((int(NumSubpixel) * 4))) -type RenderQueryPictFormatsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFormats uint32 - NumScreens uint32 - NumDepths uint32 - NumVisuals uint32 - NumSubpixel uint32 - // padding: 4 bytes - Formats []RenderPictforminfo // size: pad((int(NumFormats) * 28)) - Screens []RenderPictscreen // size: RenderPictscreenListSize(Screens) - Subpixels []uint32 // size: pad((int(NumSubpixel) * 4)) -} - -// Waits and reads reply data from request RenderQueryPictFormats -func (cook RenderQueryPictFormatsCookie) Reply() (*RenderQueryPictFormatsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryPictFormatsReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryPictFormats -func renderQueryPictFormatsReply(buf []byte) *RenderQueryPictFormatsReply { - v := new(RenderQueryPictFormatsReply) - 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.NumFormats = Get32(buf[b:]) - b += 4 - - v.NumScreens = Get32(buf[b:]) - b += 4 - - v.NumDepths = Get32(buf[b:]) - b += 4 - - v.NumVisuals = Get32(buf[b:]) - b += 4 - - v.NumSubpixel = Get32(buf[b:]) - b += 4 - - b += 4 // padding - - v.Formats = make([]RenderPictforminfo, v.NumFormats) - b += ReadRenderPictforminfoList(buf[b:], v.Formats) - - v.Screens = make([]RenderPictscreen, v.NumScreens) - b += ReadRenderPictscreenList(buf[b:], v.Screens) - - v.Subpixels = make([]uint32, v.NumSubpixel) - for i := 0; i < int(v.NumSubpixel); i++ { - v.Subpixels[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RenderQueryPictFormatsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryPictFormats -func (c *Conn) renderQueryPictFormatsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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 RenderQueryPictIndexValues -// size: 8 -type RenderQueryPictIndexValuesCookie struct { - *cookie -} - -func (c *Conn) RenderQueryPictIndexValues(Format RenderPictformat) RenderQueryPictIndexValuesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryPictIndexValuesRequest(Format), cookie) - return RenderQueryPictIndexValuesCookie{cookie} -} - -func (c *Conn) RenderQueryPictIndexValuesUnchecked(Format RenderPictformat) RenderQueryPictIndexValuesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryPictIndexValuesRequest(Format), cookie) - return RenderQueryPictIndexValuesCookie{cookie} -} - -// Request reply for RenderQueryPictIndexValues -// size: (32 + pad((int(NumValues) * 12))) -type RenderQueryPictIndexValuesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumValues uint32 - // padding: 20 bytes - Values []RenderIndexvalue // size: pad((int(NumValues) * 12)) -} - -// Waits and reads reply data from request RenderQueryPictIndexValues -func (cook RenderQueryPictIndexValuesCookie) Reply() (*RenderQueryPictIndexValuesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryPictIndexValuesReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryPictIndexValues -func renderQueryPictIndexValuesReply(buf []byte) *RenderQueryPictIndexValuesReply { - v := new(RenderQueryPictIndexValuesReply) - 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.NumValues = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Values = make([]RenderIndexvalue, v.NumValues) - b += ReadRenderIndexvalueList(buf[b:], v.Values) - - return v -} - -func (cook RenderQueryPictIndexValuesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryPictIndexValues -func (c *Conn) renderQueryPictIndexValuesRequest(Format RenderPictformat) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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(Format)) - b += 4 - - return buf -} - -// Request RenderCreatePicture -// size: pad((16 + (4 + pad((4 * popCount(int(ValueMask))))))) -type RenderCreatePictureCookie struct { - *cookie -} - -// Write request to wire for RenderCreatePicture -func (c *Conn) RenderCreatePicture(Pid RenderPicture, Drawable Drawable, Format RenderPictformat, ValueMask uint32, ValueList []uint32) RenderCreatePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreatePictureRequest(Pid, Drawable, Format, ValueMask, ValueList), cookie) - return RenderCreatePictureCookie{cookie} -} - -func (c *Conn) RenderCreatePictureChecked(Pid RenderPicture, Drawable Drawable, Format RenderPictformat, ValueMask uint32, ValueList []uint32) RenderCreatePictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreatePictureRequest(Pid, Drawable, Format, ValueMask, ValueList), cookie) - return RenderCreatePictureCookie{cookie} -} - -func (cook RenderCreatePictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreatePicture -func (c *Conn) renderCreatePictureRequest(Pid RenderPicture, Drawable Drawable, Format RenderPictformat, ValueMask uint32, ValueList []uint32) []byte { - size := pad((16 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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(Pid)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Format)) - 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 RenderChangePicture -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type RenderChangePictureCookie struct { - *cookie -} - -// Write request to wire for RenderChangePicture -func (c *Conn) RenderChangePicture(Picture RenderPicture, ValueMask uint32, ValueList []uint32) RenderChangePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderChangePictureRequest(Picture, ValueMask, ValueList), cookie) - return RenderChangePictureCookie{cookie} -} - -func (c *Conn) RenderChangePictureChecked(Picture RenderPicture, ValueMask uint32, ValueList []uint32) RenderChangePictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderChangePictureRequest(Picture, ValueMask, ValueList), cookie) - return RenderChangePictureCookie{cookie} -} - -func (cook RenderChangePictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderChangePicture -func (c *Conn) renderChangePictureRequest(Picture RenderPicture, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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(Picture)) - 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 RenderSetPictureClipRectangles -// size: pad((12 + pad((len(Rectangles) * 8)))) -type RenderSetPictureClipRectanglesCookie struct { - *cookie -} - -// Write request to wire for RenderSetPictureClipRectangles -func (c *Conn) RenderSetPictureClipRectangles(Picture RenderPicture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) RenderSetPictureClipRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureClipRectanglesRequest(Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return RenderSetPictureClipRectanglesCookie{cookie} -} - -func (c *Conn) RenderSetPictureClipRectanglesChecked(Picture RenderPicture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) RenderSetPictureClipRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderSetPictureClipRectanglesRequest(Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return RenderSetPictureClipRectanglesCookie{cookie} -} - -func (cook RenderSetPictureClipRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderSetPictureClipRectangles -func (c *Conn) renderSetPictureClipRectanglesRequest(Picture RenderPicture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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(Picture)) - b += 4 - - Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request RenderFreePicture -// size: 8 -type RenderFreePictureCookie struct { - *cookie -} - -// Write request to wire for RenderFreePicture -func (c *Conn) RenderFreePicture(Picture RenderPicture) RenderFreePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreePictureRequest(Picture), cookie) - return RenderFreePictureCookie{cookie} -} - -func (c *Conn) RenderFreePictureChecked(Picture RenderPicture) RenderFreePictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFreePictureRequest(Picture), cookie) - return RenderFreePictureCookie{cookie} -} - -func (cook RenderFreePictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFreePicture -func (c *Conn) renderFreePictureRequest(Picture RenderPicture) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - 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(Picture)) - b += 4 - - return buf -} - -// Request RenderComposite -// size: 36 -type RenderCompositeCookie struct { - *cookie -} - -// Write request to wire for RenderComposite -func (c *Conn) RenderComposite(Op byte, Src RenderPicture, Mask RenderPicture, Dst RenderPicture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) RenderCompositeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeRequest(Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return RenderCompositeCookie{cookie} -} - -func (c *Conn) RenderCompositeChecked(Op byte, Src RenderPicture, Mask RenderPicture, Dst RenderPicture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) RenderCompositeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeRequest(Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return RenderCompositeCookie{cookie} -} - -func (cook RenderCompositeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderComposite -func (c *Conn) renderCompositeRequest(Op byte, Src RenderPicture, Mask RenderPicture, Dst RenderPicture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Mask)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], uint16(MaskX)) - b += 2 - - Put16(buf[b:], uint16(MaskY)) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request RenderTrapezoids -// size: pad((24 + pad((len(Traps) * 40)))) -type RenderTrapezoidsCookie struct { - *cookie -} - -// Write request to wire for RenderTrapezoids -func (c *Conn) RenderTrapezoids(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Traps []RenderTrapezoid) RenderTrapezoidsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTrapezoidsRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return RenderTrapezoidsCookie{cookie} -} - -func (c *Conn) RenderTrapezoidsChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Traps []RenderTrapezoid) RenderTrapezoidsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTrapezoidsRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return RenderTrapezoidsCookie{cookie} -} - -func (cook RenderTrapezoidsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTrapezoids -func (c *Conn) renderTrapezoidsRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Traps []RenderTrapezoid) []byte { - size := pad((24 + pad((len(Traps) * 40)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderTrapezoidListBytes(buf[b:], Traps) - - return buf -} - -// Request RenderTriangles -// size: pad((24 + pad((len(Triangles) * 24)))) -type RenderTrianglesCookie struct { - *cookie -} - -// Write request to wire for RenderTriangles -func (c *Conn) RenderTriangles(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Triangles []RenderTriangle) RenderTrianglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTrianglesRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return RenderTrianglesCookie{cookie} -} - -func (c *Conn) RenderTrianglesChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Triangles []RenderTriangle) RenderTrianglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTrianglesRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return RenderTrianglesCookie{cookie} -} - -func (cook RenderTrianglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTriangles -func (c *Conn) renderTrianglesRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Triangles []RenderTriangle) []byte { - size := pad((24 + pad((len(Triangles) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderTriangleListBytes(buf[b:], Triangles) - - return buf -} - -// Request RenderTriStrip -// size: pad((24 + pad((len(Points) * 8)))) -type RenderTriStripCookie struct { - *cookie -} - -// Write request to wire for RenderTriStrip -func (c *Conn) RenderTriStrip(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriStripCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTriStripRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriStripCookie{cookie} -} - -func (c *Conn) RenderTriStripChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriStripCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTriStripRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriStripCookie{cookie} -} - -func (cook RenderTriStripCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTriStrip -func (c *Conn) renderTriStripRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) []byte { - size := pad((24 + pad((len(Points) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderPointfixListBytes(buf[b:], Points) - - return buf -} - -// Request RenderTriFan -// size: pad((24 + pad((len(Points) * 8)))) -type RenderTriFanCookie struct { - *cookie -} - -// Write request to wire for RenderTriFan -func (c *Conn) RenderTriFan(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriFanCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTriFanRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriFanCookie{cookie} -} - -func (c *Conn) RenderTriFanChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriFanCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTriFanRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriFanCookie{cookie} -} - -func (cook RenderTriFanCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTriFan -func (c *Conn) renderTriFanRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) []byte { - size := pad((24 + pad((len(Points) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderPointfixListBytes(buf[b:], Points) - - return buf -} - -// Request RenderCreateGlyphSet -// size: 12 -type RenderCreateGlyphSetCookie struct { - *cookie -} - -// Write request to wire for RenderCreateGlyphSet -func (c *Conn) RenderCreateGlyphSet(Gsid RenderGlyphset, Format RenderPictformat) RenderCreateGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateGlyphSetRequest(Gsid, Format), cookie) - return RenderCreateGlyphSetCookie{cookie} -} - -func (c *Conn) RenderCreateGlyphSetChecked(Gsid RenderGlyphset, Format RenderPictformat) RenderCreateGlyphSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateGlyphSetRequest(Gsid, Format), cookie) - return RenderCreateGlyphSetCookie{cookie} -} - -func (cook RenderCreateGlyphSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateGlyphSet -func (c *Conn) renderCreateGlyphSetRequest(Gsid RenderGlyphset, Format RenderPictformat) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gsid)) - b += 4 - - Put32(buf[b:], uint32(Format)) - b += 4 - - return buf -} - -// Request RenderReferenceGlyphSet -// size: 12 -type RenderReferenceGlyphSetCookie struct { - *cookie -} - -// Write request to wire for RenderReferenceGlyphSet -func (c *Conn) RenderReferenceGlyphSet(Gsid RenderGlyphset, Existing RenderGlyphset) RenderReferenceGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderReferenceGlyphSetRequest(Gsid, Existing), cookie) - return RenderReferenceGlyphSetCookie{cookie} -} - -func (c *Conn) RenderReferenceGlyphSetChecked(Gsid RenderGlyphset, Existing RenderGlyphset) RenderReferenceGlyphSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderReferenceGlyphSetRequest(Gsid, Existing), cookie) - return RenderReferenceGlyphSetCookie{cookie} -} - -func (cook RenderReferenceGlyphSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderReferenceGlyphSet -func (c *Conn) renderReferenceGlyphSetRequest(Gsid RenderGlyphset, Existing RenderGlyphset) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gsid)) - b += 4 - - Put32(buf[b:], uint32(Existing)) - b += 4 - - return buf -} - -// Request RenderFreeGlyphSet -// size: 8 -type RenderFreeGlyphSetCookie struct { - *cookie -} - -// Write request to wire for RenderFreeGlyphSet -func (c *Conn) RenderFreeGlyphSet(Glyphset RenderGlyphset) RenderFreeGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreeGlyphSetRequest(Glyphset), cookie) - return RenderFreeGlyphSetCookie{cookie} -} - -func (c *Conn) RenderFreeGlyphSetChecked(Glyphset RenderGlyphset) RenderFreeGlyphSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFreeGlyphSetRequest(Glyphset), cookie) - return RenderFreeGlyphSetCookie{cookie} -} - -func (cook RenderFreeGlyphSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFreeGlyphSet -func (c *Conn) renderFreeGlyphSetRequest(Glyphset RenderGlyphset) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - return buf -} - -// Request RenderAddGlyphs -// size: pad((((12 + pad((int(GlyphsLen) * 4))) + pad((int(GlyphsLen) * 12))) + pad((len(Data) * 1)))) -type RenderAddGlyphsCookie struct { - *cookie -} - -// Write request to wire for RenderAddGlyphs -func (c *Conn) RenderAddGlyphs(Glyphset RenderGlyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []RenderGlyphinfo, Data []byte) RenderAddGlyphsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderAddGlyphsRequest(Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return RenderAddGlyphsCookie{cookie} -} - -func (c *Conn) RenderAddGlyphsChecked(Glyphset RenderGlyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []RenderGlyphinfo, Data []byte) RenderAddGlyphsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderAddGlyphsRequest(Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return RenderAddGlyphsCookie{cookie} -} - -func (cook RenderAddGlyphsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderAddGlyphs -func (c *Conn) renderAddGlyphsRequest(Glyphset RenderGlyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []RenderGlyphinfo, Data []byte) []byte { - size := pad((((12 + pad((int(GlyphsLen) * 4))) + pad((int(GlyphsLen) * 12))) + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put32(buf[b:], GlyphsLen) - b += 4 - - for i := 0; i < int(GlyphsLen); i++ { - Put32(buf[b:], Glyphids[i]) - b += 4 - } - b = pad(b) - - b += RenderGlyphinfoListBytes(buf[b:], Glyphs) - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request RenderFreeGlyphs -// size: pad((8 + pad((len(Glyphs) * 4)))) -type RenderFreeGlyphsCookie struct { - *cookie -} - -// Write request to wire for RenderFreeGlyphs -func (c *Conn) RenderFreeGlyphs(Glyphset RenderGlyphset, Glyphs []RenderGlyph) RenderFreeGlyphsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreeGlyphsRequest(Glyphset, Glyphs), cookie) - return RenderFreeGlyphsCookie{cookie} -} - -func (c *Conn) RenderFreeGlyphsChecked(Glyphset RenderGlyphset, Glyphs []RenderGlyph) RenderFreeGlyphsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFreeGlyphsRequest(Glyphset, Glyphs), cookie) - return RenderFreeGlyphsCookie{cookie} -} - -func (cook RenderFreeGlyphsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFreeGlyphs -func (c *Conn) renderFreeGlyphsRequest(Glyphset RenderGlyphset, Glyphs []RenderGlyph) []byte { - size := pad((8 + pad((len(Glyphs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - for i := 0; i < int(len(Glyphs)); i++ { - Put32(buf[b:], uint32(Glyphs[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RenderCompositeGlyphs8 -// size: pad((28 + pad((len(Glyphcmds) * 1)))) -type RenderCompositeGlyphs8Cookie struct { - *cookie -} - -// Write request to wire for RenderCompositeGlyphs8 -func (c *Conn) RenderCompositeGlyphs8(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs8Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeGlyphs8Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs8Cookie{cookie} -} - -func (c *Conn) RenderCompositeGlyphs8Checked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs8Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeGlyphs8Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs8Cookie{cookie} -} - -func (cook RenderCompositeGlyphs8Cookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCompositeGlyphs8 -func (c *Conn) renderCompositeGlyphs8Request(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := pad((28 + pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += pad(int(len(Glyphcmds))) - - return buf -} - -// Request RenderCompositeGlyphs16 -// size: pad((28 + pad((len(Glyphcmds) * 1)))) -type RenderCompositeGlyphs16Cookie struct { - *cookie -} - -// Write request to wire for RenderCompositeGlyphs16 -func (c *Conn) RenderCompositeGlyphs16(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs16Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeGlyphs16Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs16Cookie{cookie} -} - -func (c *Conn) RenderCompositeGlyphs16Checked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs16Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeGlyphs16Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs16Cookie{cookie} -} - -func (cook RenderCompositeGlyphs16Cookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCompositeGlyphs16 -func (c *Conn) renderCompositeGlyphs16Request(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := pad((28 + pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += pad(int(len(Glyphcmds))) - - return buf -} - -// Request RenderCompositeGlyphs32 -// size: pad((28 + pad((len(Glyphcmds) * 1)))) -type RenderCompositeGlyphs32Cookie struct { - *cookie -} - -// Write request to wire for RenderCompositeGlyphs32 -func (c *Conn) RenderCompositeGlyphs32(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs32Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeGlyphs32Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs32Cookie{cookie} -} - -func (c *Conn) RenderCompositeGlyphs32Checked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs32Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeGlyphs32Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs32Cookie{cookie} -} - -func (cook RenderCompositeGlyphs32Cookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCompositeGlyphs32 -func (c *Conn) renderCompositeGlyphs32Request(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := pad((28 + pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += pad(int(len(Glyphcmds))) - - return buf -} - -// Request RenderFillRectangles -// size: pad((20 + pad((len(Rects) * 8)))) -type RenderFillRectanglesCookie struct { - *cookie -} - -// Write request to wire for RenderFillRectangles -func (c *Conn) RenderFillRectangles(Op byte, Dst RenderPicture, Color RenderColor, Rects []Rectangle) RenderFillRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFillRectanglesRequest(Op, Dst, Color, Rects), cookie) - return RenderFillRectanglesCookie{cookie} -} - -func (c *Conn) RenderFillRectanglesChecked(Op byte, Dst RenderPicture, Color RenderColor, Rects []Rectangle) RenderFillRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFillRectanglesRequest(Op, Dst, Color, Rects), cookie) - return RenderFillRectanglesCookie{cookie} -} - -func (cook RenderFillRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFillRectangles -func (c *Conn) renderFillRectanglesRequest(Op byte, Dst RenderPicture, Color RenderColor, Rects []Rectangle) []byte { - size := pad((20 + pad((len(Rects) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Dst)) - b += 4 - - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - b += RectangleListBytes(buf[b:], Rects) - - return buf -} - -// Request RenderCreateCursor -// size: 16 -type RenderCreateCursorCookie struct { - *cookie -} - -// Write request to wire for RenderCreateCursor -func (c *Conn) RenderCreateCursor(Cid Cursor, Source RenderPicture, X uint16, Y uint16) RenderCreateCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateCursorRequest(Cid, Source, X, Y), cookie) - return RenderCreateCursorCookie{cookie} -} - -func (c *Conn) RenderCreateCursorChecked(Cid Cursor, Source RenderPicture, X uint16, Y uint16) RenderCreateCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateCursorRequest(Cid, Source, X, Y), cookie) - return RenderCreateCursorCookie{cookie} -} - -func (cook RenderCreateCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateCursor -func (c *Conn) renderCreateCursorRequest(Cid Cursor, Source RenderPicture, X uint16, Y uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put16(buf[b:], X) - b += 2 - - Put16(buf[b:], Y) - b += 2 - - return buf -} - -// Request RenderSetPictureTransform -// size: 44 -type RenderSetPictureTransformCookie struct { - *cookie -} - -// Write request to wire for RenderSetPictureTransform -func (c *Conn) RenderSetPictureTransform(Picture RenderPicture, Transform RenderTransform) RenderSetPictureTransformCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureTransformRequest(Picture, Transform), cookie) - return RenderSetPictureTransformCookie{cookie} -} - -func (c *Conn) RenderSetPictureTransformChecked(Picture RenderPicture, Transform RenderTransform) RenderSetPictureTransformCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderSetPictureTransformRequest(Picture, Transform), cookie) - return RenderSetPictureTransformCookie{cookie} -} - -func (cook RenderSetPictureTransformCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderSetPictureTransform -func (c *Conn) renderSetPictureTransformRequest(Picture RenderPicture, Transform RenderTransform) []byte { - size := 44 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request RenderQueryFilters -// size: 8 -type RenderQueryFiltersCookie struct { - *cookie -} - -func (c *Conn) RenderQueryFilters(Drawable Drawable) RenderQueryFiltersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryFiltersRequest(Drawable), cookie) - return RenderQueryFiltersCookie{cookie} -} - -func (c *Conn) RenderQueryFiltersUnchecked(Drawable Drawable) RenderQueryFiltersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryFiltersRequest(Drawable), cookie) - return RenderQueryFiltersCookie{cookie} -} - -// Request reply for RenderQueryFilters -// size: ((32 + pad((int(NumAliases) * 2))) + StrListSize(Filters)) -type RenderQueryFiltersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAliases uint32 - NumFilters uint32 - // padding: 16 bytes - Aliases []uint16 // size: pad((int(NumAliases) * 2)) - Filters []Str // size: StrListSize(Filters) -} - -// Waits and reads reply data from request RenderQueryFilters -func (cook RenderQueryFiltersCookie) Reply() (*RenderQueryFiltersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryFiltersReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryFilters -func renderQueryFiltersReply(buf []byte) *RenderQueryFiltersReply { - v := new(RenderQueryFiltersReply) - 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.NumAliases = Get32(buf[b:]) - b += 4 - - v.NumFilters = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.Aliases = make([]uint16, v.NumAliases) - for i := 0; i < int(v.NumAliases); i++ { - v.Aliases[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Filters = make([]Str, v.NumFilters) - b += ReadStrList(buf[b:], v.Filters) - - return v -} - -func (cook RenderQueryFiltersCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryFilters -func (c *Conn) renderQueryFiltersRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 29 // 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 RenderSetPictureFilter -// size: pad(((12 + pad((int(FilterLen) * 1))) + pad((len(Values) * 4)))) -type RenderSetPictureFilterCookie struct { - *cookie -} - -// Write request to wire for RenderSetPictureFilter -func (c *Conn) RenderSetPictureFilter(Picture RenderPicture, FilterLen uint16, Filter string, Values []RenderFixed) RenderSetPictureFilterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureFilterRequest(Picture, FilterLen, Filter, Values), cookie) - return RenderSetPictureFilterCookie{cookie} -} - -func (c *Conn) RenderSetPictureFilterChecked(Picture RenderPicture, FilterLen uint16, Filter string, Values []RenderFixed) RenderSetPictureFilterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderSetPictureFilterRequest(Picture, FilterLen, Filter, Values), cookie) - return RenderSetPictureFilterCookie{cookie} -} - -func (cook RenderSetPictureFilterCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderSetPictureFilter -func (c *Conn) renderSetPictureFilterRequest(Picture RenderPicture, FilterLen uint16, Filter string, Values []RenderFixed) []byte { - size := pad(((12 + pad((int(FilterLen) * 1))) + pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put16(buf[b:], FilterLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Filter[:FilterLen]) - b += pad(int(FilterLen)) - - for i := 0; i < int(len(Values)); i++ { - Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RenderCreateAnimCursor -// size: pad((8 + pad((len(Cursors) * 8)))) -type RenderCreateAnimCursorCookie struct { - *cookie -} - -// Write request to wire for RenderCreateAnimCursor -func (c *Conn) RenderCreateAnimCursor(Cid Cursor, Cursors []RenderAnimcursorelt) RenderCreateAnimCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateAnimCursorRequest(Cid, Cursors), cookie) - return RenderCreateAnimCursorCookie{cookie} -} - -func (c *Conn) RenderCreateAnimCursorChecked(Cid Cursor, Cursors []RenderAnimcursorelt) RenderCreateAnimCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateAnimCursorRequest(Cid, Cursors), cookie) - return RenderCreateAnimCursorCookie{cookie} -} - -func (cook RenderCreateAnimCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateAnimCursor -func (c *Conn) renderCreateAnimCursorRequest(Cid Cursor, Cursors []RenderAnimcursorelt) []byte { - size := pad((8 + pad((len(Cursors) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 31 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - b += RenderAnimcursoreltListBytes(buf[b:], Cursors) - - return buf -} - -// Request RenderAddTraps -// size: pad((12 + pad((len(Traps) * 24)))) -type RenderAddTrapsCookie struct { - *cookie -} - -// Write request to wire for RenderAddTraps -func (c *Conn) RenderAddTraps(Picture RenderPicture, XOff int16, YOff int16, Traps []RenderTrap) RenderAddTrapsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderAddTrapsRequest(Picture, XOff, YOff, Traps), cookie) - return RenderAddTrapsCookie{cookie} -} - -func (c *Conn) RenderAddTrapsChecked(Picture RenderPicture, XOff int16, YOff int16, Traps []RenderTrap) RenderAddTrapsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderAddTrapsRequest(Picture, XOff, YOff, Traps), cookie) - return RenderAddTrapsCookie{cookie} -} - -func (cook RenderAddTrapsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderAddTraps -func (c *Conn) renderAddTrapsRequest(Picture RenderPicture, XOff int16, YOff int16, Traps []RenderTrap) []byte { - size := pad((12 + pad((len(Traps) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 32 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put16(buf[b:], uint16(XOff)) - b += 2 - - Put16(buf[b:], uint16(YOff)) - b += 2 - - b += RenderTrapListBytes(buf[b:], Traps) - - return buf -} - -// Request RenderCreateSolidFill -// size: 16 -type RenderCreateSolidFillCookie struct { - *cookie -} - -// Write request to wire for RenderCreateSolidFill -func (c *Conn) RenderCreateSolidFill(Picture RenderPicture, Color RenderColor) RenderCreateSolidFillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateSolidFillRequest(Picture, Color), cookie) - return RenderCreateSolidFillCookie{cookie} -} - -func (c *Conn) RenderCreateSolidFillChecked(Picture RenderPicture, Color RenderColor) RenderCreateSolidFillCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateSolidFillRequest(Picture, Color), cookie) - return RenderCreateSolidFillCookie{cookie} -} - -func (cook RenderCreateSolidFillCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateSolidFill -func (c *Conn) renderCreateSolidFillRequest(Picture RenderPicture, Color RenderColor) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 33 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request RenderCreateLinearGradient -// size: pad(((28 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) -type RenderCreateLinearGradientCookie struct { - *cookie -} - -// Write request to wire for RenderCreateLinearGradient -func (c *Conn) RenderCreateLinearGradient(Picture RenderPicture, P1 RenderPointfix, P2 RenderPointfix, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateLinearGradientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateLinearGradientRequest(Picture, P1, P2, NumStops, Stops, Colors), cookie) - return RenderCreateLinearGradientCookie{cookie} -} - -func (c *Conn) RenderCreateLinearGradientChecked(Picture RenderPicture, P1 RenderPointfix, P2 RenderPointfix, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateLinearGradientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateLinearGradientRequest(Picture, P1, P2, NumStops, Stops, Colors), cookie) - return RenderCreateLinearGradientCookie{cookie} -} - -func (cook RenderCreateLinearGradientCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateLinearGradient -func (c *Conn) renderCreateLinearGradientRequest(Picture RenderPicture, P1 RenderPointfix, P2 RenderPointfix, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) []byte { - size := pad(((28 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 34 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := P1.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := P2.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = pad(b) - - b += RenderColorListBytes(buf[b:], Colors) - - return buf -} - -// Request RenderCreateRadialGradient -// size: pad(((36 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) -type RenderCreateRadialGradientCookie struct { - *cookie -} - -// Write request to wire for RenderCreateRadialGradient -func (c *Conn) RenderCreateRadialGradient(Picture RenderPicture, Inner RenderPointfix, Outer RenderPointfix, InnerRadius RenderFixed, OuterRadius RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateRadialGradientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateRadialGradientRequest(Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) - return RenderCreateRadialGradientCookie{cookie} -} - -func (c *Conn) RenderCreateRadialGradientChecked(Picture RenderPicture, Inner RenderPointfix, Outer RenderPointfix, InnerRadius RenderFixed, OuterRadius RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateRadialGradientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateRadialGradientRequest(Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) - return RenderCreateRadialGradientCookie{cookie} -} - -func (cook RenderCreateRadialGradientCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateRadialGradient -func (c *Conn) renderCreateRadialGradientRequest(Picture RenderPicture, Inner RenderPointfix, Outer RenderPointfix, InnerRadius RenderFixed, OuterRadius RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) []byte { - size := pad(((36 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 35 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Inner.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := Outer.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(InnerRadius)) - b += 4 - - Put32(buf[b:], uint32(OuterRadius)) - b += 4 - - Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = pad(b) - - b += RenderColorListBytes(buf[b:], Colors) - - return buf -} - -// Request RenderCreateConicalGradient -// size: pad(((24 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) -type RenderCreateConicalGradientCookie struct { - *cookie -} - -// Write request to wire for RenderCreateConicalGradient -func (c *Conn) RenderCreateConicalGradient(Picture RenderPicture, Center RenderPointfix, Angle RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateConicalGradientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateConicalGradientRequest(Picture, Center, Angle, NumStops, Stops, Colors), cookie) - return RenderCreateConicalGradientCookie{cookie} -} - -func (c *Conn) RenderCreateConicalGradientChecked(Picture RenderPicture, Center RenderPointfix, Angle RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateConicalGradientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateConicalGradientRequest(Picture, Center, Angle, NumStops, Stops, Colors), cookie) - return RenderCreateConicalGradientCookie{cookie} -} - -func (cook RenderCreateConicalGradientCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateConicalGradient -func (c *Conn) renderCreateConicalGradientRequest(Picture RenderPicture, Center RenderPointfix, Angle RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) []byte { - size := pad(((24 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 36 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Center.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(Angle)) - b += 4 - - Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = pad(b) - - b += RenderColorListBytes(buf[b:], Colors) - - return buf -} diff --git a/nexgb/auto_res.go b/nexgb/auto_res.go deleted file mode 100644 index a2f9914..0000000 --- a/nexgb/auto_res.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_screensaver.go b/nexgb/auto_screensaver.go deleted file mode 100644 index 4f6fea0..0000000 --- a/nexgb/auto_screensaver.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_shape.go b/nexgb/auto_shape.go deleted file mode 100644 index 90d67cf..0000000 --- a/nexgb/auto_shape.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_shm.go b/nexgb/auto_shm.go deleted file mode 100644 index 392c5ff..0000000 --- a/nexgb/auto_shm.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_sync.go b/nexgb/auto_sync.go deleted file mode 100644 index 2fc2982..0000000 --- a/nexgb/auto_sync.go +++ /dev/null @@ -1,1949 +0,0 @@ -package xgb - -/* - This file was generated by sync.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" - -// SyncInit must be called before using the SYNC extension. -func (c *Conn) SyncInit() error { - reply, err := c.QueryExtension(4, "SYNC").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named SYNC could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["SYNC"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["SYNC"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["SYNC"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["SYNC"] = make(map[int]newEventFun) - newExtErrorFuncs["SYNC"] = 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' - -const ( - SyncAlarmstateActive = 0 - SyncAlarmstateInactive = 1 - SyncAlarmstateDestroyed = 2 -) - -const ( - SyncTesttypePositiveTransition = 0 - SyncTesttypeNegativeTransition = 1 - SyncTesttypePositiveComparison = 2 - SyncTesttypeNegativeComparison = 3 -) - -const ( - SyncValuetypeAbsolute = 0 - SyncValuetypeRelative = 1 -) - -const ( - SyncCaCounter = 1 - SyncCaValueType = 2 - SyncCaValue = 4 - SyncCaTestType = 8 - SyncCaDelta = 16 - SyncCaEvents = 32 -) - -type SyncAlarm uint32 - -func (c *Conn) NewSyncAlarmId() (SyncAlarm, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return SyncAlarm(id), nil -} - -type SyncCounter uint32 - -func (c *Conn) NewSyncCounterId() (SyncCounter, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return SyncCounter(id), nil -} - -type SyncFence uint32 - -func (c *Conn) NewSyncFenceId() (SyncFence, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return SyncFence(id), nil -} - -// 'SyncInt64' struct definition -// Size: 8 -type SyncInt64 struct { - Hi int32 - Lo uint32 -} - -// Struct read SyncInt64 -func ReadSyncInt64(buf []byte, v *SyncInt64) int { - b := 0 - - v.Hi = int32(Get32(buf[b:])) - b += 4 - - v.Lo = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read SyncInt64 -func ReadSyncInt64List(buf []byte, dest []SyncInt64) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncInt64{} - b += ReadSyncInt64(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncInt64 -func (v SyncInt64) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Hi)) - b += 4 - - Put32(buf[b:], v.Lo) - b += 4 - - return buf -} - -// Write struct list SyncInt64 -func SyncInt64ListBytes(buf []byte, list []SyncInt64) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'SyncSystemcounter' struct definition -// Size: (14 + pad((int(NameLen) * 1))) -type SyncSystemcounter struct { - Counter SyncCounter - Resolution SyncInt64 - NameLen uint16 - Name string // size: pad((int(NameLen) * 1)) -} - -// Struct read SyncSystemcounter -func ReadSyncSystemcounter(buf []byte, v *SyncSystemcounter) int { - b := 0 - - v.Counter = SyncCounter(Get32(buf[b:])) - b += 4 - - v.Resolution = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.Resolution) - - v.NameLen = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return b -} - -// Struct list read SyncSystemcounter -func ReadSyncSystemcounterList(buf []byte, dest []SyncSystemcounter) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncSystemcounter{} - b += ReadSyncSystemcounter(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncSystemcounter -func (v SyncSystemcounter) Bytes() []byte { - buf := make([]byte, (14 + pad((int(v.NameLen) * 1)))) - b := 0 - - Put32(buf[b:], uint32(v.Counter)) - b += 4 - - { - structBytes := v.Resolution.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put16(buf[b:], v.NameLen) - b += 2 - - copy(buf[b:], v.Name[:v.NameLen]) - b += pad(int(v.NameLen)) - - return buf -} - -// Write struct list SyncSystemcounter -func SyncSystemcounterListBytes(buf []byte, list []SyncSystemcounter) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SyncSystemcounter -func SyncSystemcounterListSize(list []SyncSystemcounter) int { - size := 0 - for _, item := range list { - size += (14 + pad((int(item.NameLen) * 1))) - } - return size -} - -// 'SyncTrigger' struct definition -// Size: 20 -type SyncTrigger struct { - Counter SyncCounter - WaitType uint32 - WaitValue SyncInt64 - TestType uint32 -} - -// Struct read SyncTrigger -func ReadSyncTrigger(buf []byte, v *SyncTrigger) int { - b := 0 - - v.Counter = SyncCounter(Get32(buf[b:])) - b += 4 - - v.WaitType = Get32(buf[b:]) - b += 4 - - v.WaitValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.WaitValue) - - v.TestType = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read SyncTrigger -func ReadSyncTriggerList(buf []byte, dest []SyncTrigger) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncTrigger{} - b += ReadSyncTrigger(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncTrigger -func (v SyncTrigger) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - Put32(buf[b:], uint32(v.Counter)) - b += 4 - - Put32(buf[b:], v.WaitType) - b += 4 - - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], v.TestType) - b += 4 - - return buf -} - -// Write struct list SyncTrigger -func SyncTriggerListBytes(buf []byte, list []SyncTrigger) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'SyncWaitcondition' struct definition -// Size: 28 -type SyncWaitcondition struct { - Trigger SyncTrigger - EventThreshold SyncInt64 -} - -// Struct read SyncWaitcondition -func ReadSyncWaitcondition(buf []byte, v *SyncWaitcondition) int { - b := 0 - - v.Trigger = SyncTrigger{} - b += ReadSyncTrigger(buf[b:], &v.Trigger) - - v.EventThreshold = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.EventThreshold) - - return b -} - -// Struct list read SyncWaitcondition -func ReadSyncWaitconditionList(buf []byte, dest []SyncWaitcondition) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncWaitcondition{} - b += ReadSyncWaitcondition(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncWaitcondition -func (v SyncWaitcondition) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - { - structBytes := v.Trigger.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.EventThreshold.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list SyncWaitcondition -func SyncWaitconditionListBytes(buf []byte, list []SyncWaitcondition) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Event definition SyncCounterNotify (0) -// Size: 32 - -const SyncCounterNotify = 0 - -type SyncCounterNotifyEvent struct { - Sequence uint16 - Kind byte - Counter SyncCounter - WaitValue SyncInt64 - CounterValue SyncInt64 - Timestamp Timestamp - Count uint16 - Destroyed bool - // padding: 1 bytes -} - -// Event read SyncCounterNotify -func NewSyncCounterNotifyEvent(buf []byte) Event { - v := SyncCounterNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Counter = SyncCounter(Get32(buf[b:])) - b += 4 - - v.WaitValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.WaitValue) - - v.CounterValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.CounterValue) - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Count = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.Destroyed = true - } else { - v.Destroyed = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write SyncCounterNotify -func (v SyncCounterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Kind - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Counter)) - b += 4 - - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put16(buf[b:], v.Count) - b += 2 - - if v.Destroyed { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v SyncCounterNotifyEvent) ImplementsEvent() {} - -func (v SyncCounterNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SyncCounterNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, sprintf("Counter: %d", v.Counter)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, sprintf("Destroyed: %t", v.Destroyed)) - return "SyncCounterNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["SYNC"][0] = NewSyncCounterNotifyEvent -} - -// Event definition SyncAlarmNotify (1) -// Size: 32 - -const SyncAlarmNotify = 1 - -type SyncAlarmNotifyEvent struct { - Sequence uint16 - Kind byte - Alarm SyncAlarm - CounterValue SyncInt64 - AlarmValue SyncInt64 - Timestamp Timestamp - State byte - // padding: 3 bytes -} - -// Event read SyncAlarmNotify -func NewSyncAlarmNotifyEvent(buf []byte) Event { - v := SyncAlarmNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Alarm = SyncAlarm(Get32(buf[b:])) - b += 4 - - v.CounterValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.CounterValue) - - v.AlarmValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.AlarmValue) - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write SyncAlarmNotify -func (v SyncAlarmNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Kind - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Alarm)) - b += 4 - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.AlarmValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - - return buf -} - -func (v SyncAlarmNotifyEvent) ImplementsEvent() {} - -func (v SyncAlarmNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SyncAlarmNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, sprintf("Alarm: %d", v.Alarm)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "SyncAlarmNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["SYNC"][1] = NewSyncAlarmNotifyEvent -} - -// Error definition SyncCounter (0) -// Size: 32 - -const BadSyncCounter = 0 - -type SyncCounterError struct { - Sequence uint16 - NiceName string - BadCounter uint32 - MinorOpcode uint16 - MajorOpcode byte -} - -// Error read SyncCounter -func NewSyncCounterError(buf []byte) Error { - v := SyncCounterError{} - v.NiceName = "SyncCounter" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadCounter = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -func (err SyncCounterError) ImplementsError() {} - -func (err SyncCounterError) SequenceId() uint16 { - return err.Sequence -} - -func (err SyncCounterError) BadId() uint32 { - return 0 -} - -func (err SyncCounterError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadCounter: %d", err.BadCounter)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadSyncCounter {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["SYNC"][0] = NewSyncCounterError -} - -// Error definition SyncAlarm (1) -// Size: 32 - -const BadSyncAlarm = 1 - -type SyncAlarmError struct { - Sequence uint16 - NiceName string - BadAlarm uint32 - MinorOpcode uint16 - MajorOpcode byte -} - -// Error read SyncAlarm -func NewSyncAlarmError(buf []byte) Error { - v := SyncAlarmError{} - v.NiceName = "SyncAlarm" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadAlarm = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -func (err SyncAlarmError) ImplementsError() {} - -func (err SyncAlarmError) SequenceId() uint16 { - return err.Sequence -} - -func (err SyncAlarmError) BadId() uint32 { - return 0 -} - -func (err SyncAlarmError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadAlarm: %d", err.BadAlarm)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadSyncAlarm {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["SYNC"][1] = NewSyncAlarmError -} - -// Request SyncInitialize -// size: 8 -type SyncInitializeCookie struct { - *cookie -} - -func (c *Conn) SyncInitialize(DesiredMajorVersion byte, DesiredMinorVersion byte) SyncInitializeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncInitializeRequest(DesiredMajorVersion, DesiredMinorVersion), cookie) - return SyncInitializeCookie{cookie} -} - -func (c *Conn) SyncInitializeUnchecked(DesiredMajorVersion byte, DesiredMinorVersion byte) SyncInitializeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncInitializeRequest(DesiredMajorVersion, DesiredMinorVersion), cookie) - return SyncInitializeCookie{cookie} -} - -// Request reply for SyncInitialize -// size: 32 -type SyncInitializeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion byte - MinorVersion byte - // padding: 22 bytes -} - -// Waits and reads reply data from request SyncInitialize -func (cook SyncInitializeCookie) Reply() (*SyncInitializeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncInitializeReply(buf), nil -} - -// Read reply into structure from buffer for SyncInitialize -func syncInitializeReply(buf []byte) *SyncInitializeReply { - v := new(SyncInitializeReply) - 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 = buf[b] - b += 1 - - v.MinorVersion = buf[b] - b += 1 - - b += 22 // padding - - return v -} - -func (cook SyncInitializeCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncInitialize -func (c *Conn) syncInitializeRequest(DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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] = DesiredMajorVersion - b += 1 - - buf[b] = DesiredMinorVersion - b += 1 - - return buf -} - -// Request SyncListSystemCounters -// size: 4 -type SyncListSystemCountersCookie struct { - *cookie -} - -func (c *Conn) SyncListSystemCounters() SyncListSystemCountersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncListSystemCountersRequest(), cookie) - return SyncListSystemCountersCookie{cookie} -} - -func (c *Conn) SyncListSystemCountersUnchecked() SyncListSystemCountersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncListSystemCountersRequest(), cookie) - return SyncListSystemCountersCookie{cookie} -} - -// Request reply for SyncListSystemCounters -// size: (32 + SyncSystemcounterListSize(Counters)) -type SyncListSystemCountersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - CountersLen uint32 - // padding: 20 bytes - Counters []SyncSystemcounter // size: SyncSystemcounterListSize(Counters) -} - -// Waits and reads reply data from request SyncListSystemCounters -func (cook SyncListSystemCountersCookie) Reply() (*SyncListSystemCountersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncListSystemCountersReply(buf), nil -} - -// Read reply into structure from buffer for SyncListSystemCounters -func syncListSystemCountersReply(buf []byte) *SyncListSystemCountersReply { - v := new(SyncListSystemCountersReply) - 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.CountersLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Counters = make([]SyncSystemcounter, v.CountersLen) - b += ReadSyncSystemcounterList(buf[b:], v.Counters) - - return v -} - -func (cook SyncListSystemCountersCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncListSystemCounters -func (c *Conn) syncListSystemCountersRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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 SyncCreateCounter -// size: 16 -type SyncCreateCounterCookie struct { - *cookie -} - -// Write request to wire for SyncCreateCounter -func (c *Conn) SyncCreateCounter(Id SyncCounter, InitialValue SyncInt64) SyncCreateCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncCreateCounterRequest(Id, InitialValue), cookie) - return SyncCreateCounterCookie{cookie} -} - -func (c *Conn) SyncCreateCounterChecked(Id SyncCounter, InitialValue SyncInt64) SyncCreateCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncCreateCounterRequest(Id, InitialValue), cookie) - return SyncCreateCounterCookie{cookie} -} - -func (cook SyncCreateCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncCreateCounter -func (c *Conn) syncCreateCounterRequest(Id SyncCounter, InitialValue SyncInt64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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(Id)) - b += 4 - - { - structBytes := InitialValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request SyncDestroyCounter -// size: 8 -type SyncDestroyCounterCookie struct { - *cookie -} - -// Write request to wire for SyncDestroyCounter -func (c *Conn) SyncDestroyCounter(Counter SyncCounter) SyncDestroyCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncDestroyCounterRequest(Counter), cookie) - return SyncDestroyCounterCookie{cookie} -} - -func (c *Conn) SyncDestroyCounterChecked(Counter SyncCounter) SyncDestroyCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncDestroyCounterRequest(Counter), cookie) - return SyncDestroyCounterCookie{cookie} -} - -func (cook SyncDestroyCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncDestroyCounter -func (c *Conn) syncDestroyCounterRequest(Counter SyncCounter) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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(Counter)) - b += 4 - - return buf -} - -// Request SyncQueryCounter -// size: 8 -type SyncQueryCounterCookie struct { - *cookie -} - -func (c *Conn) SyncQueryCounter(Counter SyncCounter) SyncQueryCounterCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncQueryCounterRequest(Counter), cookie) - return SyncQueryCounterCookie{cookie} -} - -func (c *Conn) SyncQueryCounterUnchecked(Counter SyncCounter) SyncQueryCounterCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncQueryCounterRequest(Counter), cookie) - return SyncQueryCounterCookie{cookie} -} - -// Request reply for SyncQueryCounter -// size: 16 -type SyncQueryCounterReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - CounterValue SyncInt64 -} - -// Waits and reads reply data from request SyncQueryCounter -func (cook SyncQueryCounterCookie) Reply() (*SyncQueryCounterReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncQueryCounterReply(buf), nil -} - -// Read reply into structure from buffer for SyncQueryCounter -func syncQueryCounterReply(buf []byte) *SyncQueryCounterReply { - v := new(SyncQueryCounterReply) - 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.CounterValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.CounterValue) - - return v -} - -func (cook SyncQueryCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncQueryCounter -func (c *Conn) syncQueryCounterRequest(Counter SyncCounter) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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(Counter)) - b += 4 - - return buf -} - -// Request SyncAwait -// size: pad((4 + pad((len(WaitList) * 28)))) -type SyncAwaitCookie struct { - *cookie -} - -// Write request to wire for SyncAwait -func (c *Conn) SyncAwait(WaitList []SyncWaitcondition) SyncAwaitCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncAwaitRequest(WaitList), cookie) - return SyncAwaitCookie{cookie} -} - -func (c *Conn) SyncAwaitChecked(WaitList []SyncWaitcondition) SyncAwaitCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncAwaitRequest(WaitList), cookie) - return SyncAwaitCookie{cookie} -} - -func (cook SyncAwaitCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncAwait -func (c *Conn) syncAwaitRequest(WaitList []SyncWaitcondition) []byte { - size := pad((4 + pad((len(WaitList) * 28)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - b += SyncWaitconditionListBytes(buf[b:], WaitList) - - return buf -} - -// Request SyncChangeCounter -// size: 16 -type SyncChangeCounterCookie struct { - *cookie -} - -// Write request to wire for SyncChangeCounter -func (c *Conn) SyncChangeCounter(Counter SyncCounter, Amount SyncInt64) SyncChangeCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncChangeCounterRequest(Counter, Amount), cookie) - return SyncChangeCounterCookie{cookie} -} - -func (c *Conn) SyncChangeCounterChecked(Counter SyncCounter, Amount SyncInt64) SyncChangeCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncChangeCounterRequest(Counter, Amount), cookie) - return SyncChangeCounterCookie{cookie} -} - -func (cook SyncChangeCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncChangeCounter -func (c *Conn) syncChangeCounterRequest(Counter SyncCounter, Amount SyncInt64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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(Counter)) - b += 4 - - { - structBytes := Amount.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request SyncSetCounter -// size: 16 -type SyncSetCounterCookie struct { - *cookie -} - -// Write request to wire for SyncSetCounter -func (c *Conn) SyncSetCounter(Counter SyncCounter, Value SyncInt64) SyncSetCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncSetCounterRequest(Counter, Value), cookie) - return SyncSetCounterCookie{cookie} -} - -func (c *Conn) SyncSetCounterChecked(Counter SyncCounter, Value SyncInt64) SyncSetCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncSetCounterRequest(Counter, Value), cookie) - return SyncSetCounterCookie{cookie} -} - -func (cook SyncSetCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncSetCounter -func (c *Conn) syncSetCounterRequest(Counter SyncCounter, Value SyncInt64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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(Counter)) - b += 4 - - { - structBytes := Value.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request SyncCreateAlarm -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type SyncCreateAlarmCookie struct { - *cookie -} - -// Write request to wire for SyncCreateAlarm -func (c *Conn) SyncCreateAlarm(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncCreateAlarmCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncCreateAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncCreateAlarmCookie{cookie} -} - -func (c *Conn) SyncCreateAlarmChecked(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncCreateAlarmCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncCreateAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncCreateAlarmCookie{cookie} -} - -func (cook SyncCreateAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncCreateAlarm -func (c *Conn) syncCreateAlarmRequest(Id SyncAlarm, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - 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(Id)) - 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 SyncChangeAlarm -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type SyncChangeAlarmCookie struct { - *cookie -} - -// Write request to wire for SyncChangeAlarm -func (c *Conn) SyncChangeAlarm(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncChangeAlarmCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncChangeAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncChangeAlarmCookie{cookie} -} - -func (c *Conn) SyncChangeAlarmChecked(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncChangeAlarmCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncChangeAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncChangeAlarmCookie{cookie} -} - -func (cook SyncChangeAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncChangeAlarm -func (c *Conn) syncChangeAlarmRequest(Id SyncAlarm, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Id)) - 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 SyncDestroyAlarm -// size: 8 -type SyncDestroyAlarmCookie struct { - *cookie -} - -// Write request to wire for SyncDestroyAlarm -func (c *Conn) SyncDestroyAlarm(Alarm SyncAlarm) SyncDestroyAlarmCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncDestroyAlarmRequest(Alarm), cookie) - return SyncDestroyAlarmCookie{cookie} -} - -func (c *Conn) SyncDestroyAlarmChecked(Alarm SyncAlarm) SyncDestroyAlarmCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncDestroyAlarmRequest(Alarm), cookie) - return SyncDestroyAlarmCookie{cookie} -} - -func (cook SyncDestroyAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncDestroyAlarm -func (c *Conn) syncDestroyAlarmRequest(Alarm SyncAlarm) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Alarm)) - b += 4 - - return buf -} - -// Request SyncQueryAlarm -// size: 8 -type SyncQueryAlarmCookie struct { - *cookie -} - -func (c *Conn) SyncQueryAlarm(Alarm SyncAlarm) SyncQueryAlarmCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncQueryAlarmRequest(Alarm), cookie) - return SyncQueryAlarmCookie{cookie} -} - -func (c *Conn) SyncQueryAlarmUnchecked(Alarm SyncAlarm) SyncQueryAlarmCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncQueryAlarmRequest(Alarm), cookie) - return SyncQueryAlarmCookie{cookie} -} - -// Request reply for SyncQueryAlarm -// size: 40 -type SyncQueryAlarmReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Trigger SyncTrigger - Delta SyncInt64 - Events bool - State byte - // padding: 2 bytes -} - -// Waits and reads reply data from request SyncQueryAlarm -func (cook SyncQueryAlarmCookie) Reply() (*SyncQueryAlarmReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncQueryAlarmReply(buf), nil -} - -// Read reply into structure from buffer for SyncQueryAlarm -func syncQueryAlarmReply(buf []byte) *SyncQueryAlarmReply { - v := new(SyncQueryAlarmReply) - 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.Trigger = SyncTrigger{} - b += ReadSyncTrigger(buf[b:], &v.Trigger) - - v.Delta = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.Delta) - - if buf[b] == 1 { - v.Events = true - } else { - v.Events = false - } - b += 1 - - v.State = buf[b] - b += 1 - - b += 2 // padding - - return v -} - -func (cook SyncQueryAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncQueryAlarm -func (c *Conn) syncQueryAlarmRequest(Alarm SyncAlarm) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Alarm)) - b += 4 - - return buf -} - -// Request SyncSetPriority -// size: 12 -type SyncSetPriorityCookie struct { - *cookie -} - -// Write request to wire for SyncSetPriority -func (c *Conn) SyncSetPriority(Id uint32, Priority int32) SyncSetPriorityCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncSetPriorityRequest(Id, Priority), cookie) - return SyncSetPriorityCookie{cookie} -} - -func (c *Conn) SyncSetPriorityChecked(Id uint32, Priority int32) SyncSetPriorityCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncSetPriorityRequest(Id, Priority), cookie) - return SyncSetPriorityCookie{cookie} -} - -func (cook SyncSetPriorityCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncSetPriority -func (c *Conn) syncSetPriorityRequest(Id uint32, Priority int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], uint32(Priority)) - b += 4 - - return buf -} - -// Request SyncGetPriority -// size: 8 -type SyncGetPriorityCookie struct { - *cookie -} - -func (c *Conn) SyncGetPriority(Id uint32) SyncGetPriorityCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncGetPriorityRequest(Id), cookie) - return SyncGetPriorityCookie{cookie} -} - -func (c *Conn) SyncGetPriorityUnchecked(Id uint32) SyncGetPriorityCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncGetPriorityRequest(Id), cookie) - return SyncGetPriorityCookie{cookie} -} - -// Request reply for SyncGetPriority -// size: 12 -type SyncGetPriorityReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Priority int32 -} - -// Waits and reads reply data from request SyncGetPriority -func (cook SyncGetPriorityCookie) Reply() (*SyncGetPriorityReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncGetPriorityReply(buf), nil -} - -// Read reply into structure from buffer for SyncGetPriority -func syncGetPriorityReply(buf []byte) *SyncGetPriorityReply { - v := new(SyncGetPriorityReply) - 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.Priority = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook SyncGetPriorityCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncGetPriority -func (c *Conn) syncGetPriorityRequest(Id uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Id) - b += 4 - - return buf -} - -// Request SyncCreateFence -// size: 16 -type SyncCreateFenceCookie struct { - *cookie -} - -// Write request to wire for SyncCreateFence -func (c *Conn) SyncCreateFence(Drawable Drawable, Fence SyncFence, InitiallyTriggered bool) SyncCreateFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncCreateFenceRequest(Drawable, Fence, InitiallyTriggered), cookie) - return SyncCreateFenceCookie{cookie} -} - -func (c *Conn) SyncCreateFenceChecked(Drawable Drawable, Fence SyncFence, InitiallyTriggered bool) SyncCreateFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncCreateFenceRequest(Drawable, Fence, InitiallyTriggered), cookie) - return SyncCreateFenceCookie{cookie} -} - -func (cook SyncCreateFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncCreateFence -func (c *Conn) syncCreateFenceRequest(Drawable Drawable, Fence SyncFence, InitiallyTriggered bool) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 14 // 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(Fence)) - b += 4 - - if InitiallyTriggered { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request SyncTriggerFence -// size: 8 -type SyncTriggerFenceCookie struct { - *cookie -} - -// Write request to wire for SyncTriggerFence -func (c *Conn) SyncTriggerFence(Fence SyncFence) SyncTriggerFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncTriggerFenceRequest(Fence), cookie) - return SyncTriggerFenceCookie{cookie} -} - -func (c *Conn) SyncTriggerFenceChecked(Fence SyncFence) SyncTriggerFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncTriggerFenceRequest(Fence), cookie) - return SyncTriggerFenceCookie{cookie} -} - -func (cook SyncTriggerFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncTriggerFence -func (c *Conn) syncTriggerFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncResetFence -// size: 8 -type SyncResetFenceCookie struct { - *cookie -} - -// Write request to wire for SyncResetFence -func (c *Conn) SyncResetFence(Fence SyncFence) SyncResetFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncResetFenceRequest(Fence), cookie) - return SyncResetFenceCookie{cookie} -} - -func (c *Conn) SyncResetFenceChecked(Fence SyncFence) SyncResetFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncResetFenceRequest(Fence), cookie) - return SyncResetFenceCookie{cookie} -} - -func (cook SyncResetFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncResetFence -func (c *Conn) syncResetFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncDestroyFence -// size: 8 -type SyncDestroyFenceCookie struct { - *cookie -} - -// Write request to wire for SyncDestroyFence -func (c *Conn) SyncDestroyFence(Fence SyncFence) SyncDestroyFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncDestroyFenceRequest(Fence), cookie) - return SyncDestroyFenceCookie{cookie} -} - -func (c *Conn) SyncDestroyFenceChecked(Fence SyncFence) SyncDestroyFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncDestroyFenceRequest(Fence), cookie) - return SyncDestroyFenceCookie{cookie} -} - -func (cook SyncDestroyFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncDestroyFence -func (c *Conn) syncDestroyFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncQueryFence -// size: 8 -type SyncQueryFenceCookie struct { - *cookie -} - -func (c *Conn) SyncQueryFence(Fence SyncFence) SyncQueryFenceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncQueryFenceRequest(Fence), cookie) - return SyncQueryFenceCookie{cookie} -} - -func (c *Conn) SyncQueryFenceUnchecked(Fence SyncFence) SyncQueryFenceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncQueryFenceRequest(Fence), cookie) - return SyncQueryFenceCookie{cookie} -} - -// Request reply for SyncQueryFence -// size: 32 -type SyncQueryFenceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Triggered bool - // padding: 23 bytes -} - -// Waits and reads reply data from request SyncQueryFence -func (cook SyncQueryFenceCookie) Reply() (*SyncQueryFenceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncQueryFenceReply(buf), nil -} - -// Read reply into structure from buffer for SyncQueryFence -func syncQueryFenceReply(buf []byte) *SyncQueryFenceReply { - v := new(SyncQueryFenceReply) - 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.Triggered = true - } else { - v.Triggered = false - } - b += 1 - - b += 23 // padding - - return v -} - -func (cook SyncQueryFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncQueryFence -func (c *Conn) syncQueryFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncAwaitFence -// size: pad((4 + pad((len(FenceList) * 4)))) -type SyncAwaitFenceCookie struct { - *cookie -} - -// Write request to wire for SyncAwaitFence -func (c *Conn) SyncAwaitFence(FenceList []SyncFence) SyncAwaitFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncAwaitFenceRequest(FenceList), cookie) - return SyncAwaitFenceCookie{cookie} -} - -func (c *Conn) SyncAwaitFenceChecked(FenceList []SyncFence) SyncAwaitFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncAwaitFenceRequest(FenceList), cookie) - return SyncAwaitFenceCookie{cookie} -} - -func (cook SyncAwaitFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncAwaitFence -func (c *Conn) syncAwaitFenceRequest(FenceList []SyncFence) []byte { - size := pad((4 + pad((len(FenceList) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - for i := 0; i < int(len(FenceList)); i++ { - Put32(buf[b:], uint32(FenceList[i])) - b += 4 - } - b = pad(b) - - return buf -} diff --git a/nexgb/auto_xc_misc.go b/nexgb/auto_xc_misc.go deleted file mode 100644 index bce7d29..0000000 --- a/nexgb/auto_xc_misc.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_xevie.go b/nexgb/auto_xevie.go deleted file mode 100644 index 33a05cf..0000000 --- a/nexgb/auto_xevie.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_xf86dri.go b/nexgb/auto_xf86dri.go deleted file mode 100644 index 4caa416..0000000 --- a/nexgb/auto_xf86dri.go +++ /dev/null @@ -1,1151 +0,0 @@ -package xgb - -/* - This file was generated by xf86dri.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Xf86driInit must be called before using the XFree86-DRI extension. -func (c *Conn) Xf86driInit() error { - reply, err := c.QueryExtension(11, "XFree86-DRI").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XFree86-DRI could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XFree86-DRI"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XFree86-DRI"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XFree86-DRI"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XFree86-DRI"] = make(map[int]newEventFun) - newExtErrorFuncs["XFree86-DRI"] = 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' - -// 'Xf86driDrmClipRect' struct definition -// Size: 8 -type Xf86driDrmClipRect struct { - X1 int16 - Y1 int16 - X2 int16 - X3 int16 -} - -// Struct read Xf86driDrmClipRect -func ReadXf86driDrmClipRect(buf []byte, v *Xf86driDrmClipRect) int { - b := 0 - - v.X1 = int16(Get16(buf[b:])) - b += 2 - - v.Y1 = int16(Get16(buf[b:])) - b += 2 - - v.X2 = int16(Get16(buf[b:])) - b += 2 - - v.X3 = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Xf86driDrmClipRect -func ReadXf86driDrmClipRectList(buf []byte, dest []Xf86driDrmClipRect) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Xf86driDrmClipRect{} - b += ReadXf86driDrmClipRect(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Xf86driDrmClipRect -func (v Xf86driDrmClipRect) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.X1)) - b += 2 - - Put16(buf[b:], uint16(v.Y1)) - b += 2 - - Put16(buf[b:], uint16(v.X2)) - b += 2 - - Put16(buf[b:], uint16(v.X3)) - b += 2 - - return buf -} - -// Write struct list Xf86driDrmClipRect -func Xf86driDrmClipRectListBytes(buf []byte, list []Xf86driDrmClipRect) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Request Xf86driQueryVersion -// size: 4 -type Xf86driQueryVersionCookie struct { - *cookie -} - -func (c *Conn) Xf86driQueryVersion() Xf86driQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driQueryVersionRequest(), cookie) - return Xf86driQueryVersionCookie{cookie} -} - -func (c *Conn) Xf86driQueryVersionUnchecked() Xf86driQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driQueryVersionRequest(), cookie) - return Xf86driQueryVersionCookie{cookie} -} - -// Request reply for Xf86driQueryVersion -// size: 16 -type Xf86driQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DriMajorVersion uint16 - DriMinorVersion uint16 - DriMinorPatch uint32 -} - -// Waits and reads reply data from request Xf86driQueryVersion -func (cook Xf86driQueryVersionCookie) Reply() (*Xf86driQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driQueryVersion -func xf86driQueryVersionReply(buf []byte) *Xf86driQueryVersionReply { - v := new(Xf86driQueryVersionReply) - 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.DriMajorVersion = Get16(buf[b:]) - b += 2 - - v.DriMinorVersion = Get16(buf[b:]) - b += 2 - - v.DriMinorPatch = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driQueryVersion -func (c *Conn) xf86driQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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 Xf86driQueryDirectRenderingCapable -// size: 8 -type Xf86driQueryDirectRenderingCapableCookie struct { - *cookie -} - -func (c *Conn) Xf86driQueryDirectRenderingCapable(Screen uint32) Xf86driQueryDirectRenderingCapableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driQueryDirectRenderingCapableRequest(Screen), cookie) - return Xf86driQueryDirectRenderingCapableCookie{cookie} -} - -func (c *Conn) Xf86driQueryDirectRenderingCapableUnchecked(Screen uint32) Xf86driQueryDirectRenderingCapableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driQueryDirectRenderingCapableRequest(Screen), cookie) - return Xf86driQueryDirectRenderingCapableCookie{cookie} -} - -// Request reply for Xf86driQueryDirectRenderingCapable -// size: 9 -type Xf86driQueryDirectRenderingCapableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - IsCapable bool -} - -// Waits and reads reply data from request Xf86driQueryDirectRenderingCapable -func (cook Xf86driQueryDirectRenderingCapableCookie) Reply() (*Xf86driQueryDirectRenderingCapableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driQueryDirectRenderingCapableReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driQueryDirectRenderingCapable -func xf86driQueryDirectRenderingCapableReply(buf []byte) *Xf86driQueryDirectRenderingCapableReply { - v := new(Xf86driQueryDirectRenderingCapableReply) - 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.IsCapable = true - } else { - v.IsCapable = false - } - b += 1 - - return v -} - -func (cook Xf86driQueryDirectRenderingCapableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driQueryDirectRenderingCapable -func (c *Conn) xf86driQueryDirectRenderingCapableRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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 Xf86driOpenConnection -// size: 8 -type Xf86driOpenConnectionCookie struct { - *cookie -} - -func (c *Conn) Xf86driOpenConnection(Screen uint32) Xf86driOpenConnectionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driOpenConnectionRequest(Screen), cookie) - return Xf86driOpenConnectionCookie{cookie} -} - -func (c *Conn) Xf86driOpenConnectionUnchecked(Screen uint32) Xf86driOpenConnectionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driOpenConnectionRequest(Screen), cookie) - return Xf86driOpenConnectionCookie{cookie} -} - -// Request reply for Xf86driOpenConnection -// size: (32 + pad((int(BusIdLen) * 1))) -type Xf86driOpenConnectionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - SareaHandleLow uint32 - SareaHandleHigh uint32 - BusIdLen uint32 - // padding: 12 bytes - BusId string // size: pad((int(BusIdLen) * 1)) -} - -// Waits and reads reply data from request Xf86driOpenConnection -func (cook Xf86driOpenConnectionCookie) Reply() (*Xf86driOpenConnectionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driOpenConnectionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driOpenConnection -func xf86driOpenConnectionReply(buf []byte) *Xf86driOpenConnectionReply { - v := new(Xf86driOpenConnectionReply) - 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.SareaHandleLow = Get32(buf[b:]) - b += 4 - - v.SareaHandleHigh = Get32(buf[b:]) - b += 4 - - v.BusIdLen = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - { - byteString := make([]byte, v.BusIdLen) - copy(byteString[:v.BusIdLen], buf[b:]) - v.BusId = string(byteString) - b += pad(int(v.BusIdLen)) - } - - return v -} - -func (cook Xf86driOpenConnectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driOpenConnection -func (c *Conn) xf86driOpenConnectionRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - return buf -} - -// Request Xf86driCloseConnection -// size: 8 -type Xf86driCloseConnectionCookie struct { - *cookie -} - -// Write request to wire for Xf86driCloseConnection -func (c *Conn) Xf86driCloseConnection(Screen uint32) Xf86driCloseConnectionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86driCloseConnectionRequest(Screen), cookie) - return Xf86driCloseConnectionCookie{cookie} -} - -func (c *Conn) Xf86driCloseConnectionChecked(Screen uint32) Xf86driCloseConnectionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86driCloseConnectionRequest(Screen), cookie) - return Xf86driCloseConnectionCookie{cookie} -} - -func (cook Xf86driCloseConnectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driCloseConnection -func (c *Conn) xf86driCloseConnectionRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - return buf -} - -// Request Xf86driGetClientDriverName -// size: 8 -type Xf86driGetClientDriverNameCookie struct { - *cookie -} - -func (c *Conn) Xf86driGetClientDriverName(Screen uint32) Xf86driGetClientDriverNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driGetClientDriverNameRequest(Screen), cookie) - return Xf86driGetClientDriverNameCookie{cookie} -} - -func (c *Conn) Xf86driGetClientDriverNameUnchecked(Screen uint32) Xf86driGetClientDriverNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driGetClientDriverNameRequest(Screen), cookie) - return Xf86driGetClientDriverNameCookie{cookie} -} - -// Request reply for Xf86driGetClientDriverName -// size: (32 + pad((int(ClientDriverNameLen) * 1))) -type Xf86driGetClientDriverNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ClientDriverMajorVersion uint32 - ClientDriverMinorVersion uint32 - ClientDriverPatchVersion uint32 - ClientDriverNameLen uint32 - // padding: 8 bytes - ClientDriverName string // size: pad((int(ClientDriverNameLen) * 1)) -} - -// Waits and reads reply data from request Xf86driGetClientDriverName -func (cook Xf86driGetClientDriverNameCookie) Reply() (*Xf86driGetClientDriverNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driGetClientDriverNameReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driGetClientDriverName -func xf86driGetClientDriverNameReply(buf []byte) *Xf86driGetClientDriverNameReply { - v := new(Xf86driGetClientDriverNameReply) - 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.ClientDriverMajorVersion = Get32(buf[b:]) - b += 4 - - v.ClientDriverMinorVersion = Get32(buf[b:]) - b += 4 - - v.ClientDriverPatchVersion = Get32(buf[b:]) - b += 4 - - v.ClientDriverNameLen = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - { - byteString := make([]byte, v.ClientDriverNameLen) - copy(byteString[:v.ClientDriverNameLen], buf[b:]) - v.ClientDriverName = string(byteString) - b += pad(int(v.ClientDriverNameLen)) - } - - return v -} - -func (cook Xf86driGetClientDriverNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driGetClientDriverName -func (c *Conn) xf86driGetClientDriverNameRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - return buf -} - -// Request Xf86driCreateContext -// size: 16 -type Xf86driCreateContextCookie struct { - *cookie -} - -func (c *Conn) Xf86driCreateContext(Screen uint32, Visual uint32, Context uint32) Xf86driCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driCreateContextRequest(Screen, Visual, Context), cookie) - return Xf86driCreateContextCookie{cookie} -} - -func (c *Conn) Xf86driCreateContextUnchecked(Screen uint32, Visual uint32, Context uint32) Xf86driCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driCreateContextRequest(Screen, Visual, Context), cookie) - return Xf86driCreateContextCookie{cookie} -} - -// Request reply for Xf86driCreateContext -// size: 12 -type Xf86driCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - HwContext uint32 -} - -// Waits and reads reply data from request Xf86driCreateContext -func (cook Xf86driCreateContextCookie) Reply() (*Xf86driCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driCreateContext -func xf86driCreateContextReply(buf []byte) *Xf86driCreateContextReply { - v := new(Xf86driCreateContextReply) - 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.HwContext = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driCreateContext -func (c *Conn) xf86driCreateContextRequest(Screen uint32, Visual uint32, Context uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - Put32(buf[b:], Visual) - b += 4 - - Put32(buf[b:], Context) - b += 4 - - return buf -} - -// Request Xf86driDestroyContext -// size: 12 -type Xf86driDestroyContextCookie struct { - *cookie -} - -// Write request to wire for Xf86driDestroyContext -func (c *Conn) Xf86driDestroyContext(Screen uint32, Context uint32) Xf86driDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86driDestroyContextRequest(Screen, Context), cookie) - return Xf86driDestroyContextCookie{cookie} -} - -func (c *Conn) Xf86driDestroyContextChecked(Screen uint32, Context uint32) Xf86driDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86driDestroyContextRequest(Screen, Context), cookie) - return Xf86driDestroyContextCookie{cookie} -} - -func (cook Xf86driDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driDestroyContext -func (c *Conn) xf86driDestroyContextRequest(Screen uint32, Context uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - Put32(buf[b:], Context) - b += 4 - - return buf -} - -// Request Xf86driCreateDrawable -// size: 12 -type Xf86driCreateDrawableCookie struct { - *cookie -} - -func (c *Conn) Xf86driCreateDrawable(Screen uint32, Drawable uint32) Xf86driCreateDrawableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driCreateDrawableRequest(Screen, Drawable), cookie) - return Xf86driCreateDrawableCookie{cookie} -} - -func (c *Conn) Xf86driCreateDrawableUnchecked(Screen uint32, Drawable uint32) Xf86driCreateDrawableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driCreateDrawableRequest(Screen, Drawable), cookie) - return Xf86driCreateDrawableCookie{cookie} -} - -// Request reply for Xf86driCreateDrawable -// size: 12 -type Xf86driCreateDrawableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - HwDrawableHandle uint32 -} - -// Waits and reads reply data from request Xf86driCreateDrawable -func (cook Xf86driCreateDrawableCookie) Reply() (*Xf86driCreateDrawableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driCreateDrawableReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driCreateDrawable -func xf86driCreateDrawableReply(buf []byte) *Xf86driCreateDrawableReply { - v := new(Xf86driCreateDrawableReply) - 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.HwDrawableHandle = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driCreateDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driCreateDrawable -func (c *Conn) xf86driCreateDrawableRequest(Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// Request Xf86driDestroyDrawable -// size: 12 -type Xf86driDestroyDrawableCookie struct { - *cookie -} - -// Write request to wire for Xf86driDestroyDrawable -func (c *Conn) Xf86driDestroyDrawable(Screen uint32, Drawable uint32) Xf86driDestroyDrawableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86driDestroyDrawableRequest(Screen, Drawable), cookie) - return Xf86driDestroyDrawableCookie{cookie} -} - -func (c *Conn) Xf86driDestroyDrawableChecked(Screen uint32, Drawable uint32) Xf86driDestroyDrawableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86driDestroyDrawableRequest(Screen, Drawable), cookie) - return Xf86driDestroyDrawableCookie{cookie} -} - -func (cook Xf86driDestroyDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driDestroyDrawable -func (c *Conn) xf86driDestroyDrawableRequest(Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - 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:], Screen) - b += 4 - - Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// Request Xf86driGetDrawableInfo -// size: 12 -type Xf86driGetDrawableInfoCookie struct { - *cookie -} - -func (c *Conn) Xf86driGetDrawableInfo(Screen uint32, Drawable uint32) Xf86driGetDrawableInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driGetDrawableInfoRequest(Screen, Drawable), cookie) - return Xf86driGetDrawableInfoCookie{cookie} -} - -func (c *Conn) Xf86driGetDrawableInfoUnchecked(Screen uint32, Drawable uint32) Xf86driGetDrawableInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driGetDrawableInfoRequest(Screen, Drawable), cookie) - return Xf86driGetDrawableInfoCookie{cookie} -} - -// Request reply for Xf86driGetDrawableInfo -// size: ((36 + pad((int(NumClipRects) * 8))) + pad((int(NumBackClipRects) * 8))) -type Xf86driGetDrawableInfoReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DrawableTableIndex uint32 - DrawableTableStamp uint32 - DrawableOriginX int16 - DrawableOriginY int16 - DrawableSizeW int16 - DrawableSizeH int16 - NumClipRects uint32 - BackX int16 - BackY int16 - NumBackClipRects uint32 - ClipRects []Xf86driDrmClipRect // size: pad((int(NumClipRects) * 8)) - BackClipRects []Xf86driDrmClipRect // size: pad((int(NumBackClipRects) * 8)) -} - -// Waits and reads reply data from request Xf86driGetDrawableInfo -func (cook Xf86driGetDrawableInfoCookie) Reply() (*Xf86driGetDrawableInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driGetDrawableInfoReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driGetDrawableInfo -func xf86driGetDrawableInfoReply(buf []byte) *Xf86driGetDrawableInfoReply { - v := new(Xf86driGetDrawableInfoReply) - 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.DrawableTableIndex = Get32(buf[b:]) - b += 4 - - v.DrawableTableStamp = Get32(buf[b:]) - b += 4 - - v.DrawableOriginX = int16(Get16(buf[b:])) - b += 2 - - v.DrawableOriginY = int16(Get16(buf[b:])) - b += 2 - - v.DrawableSizeW = int16(Get16(buf[b:])) - b += 2 - - v.DrawableSizeH = int16(Get16(buf[b:])) - b += 2 - - v.NumClipRects = Get32(buf[b:]) - b += 4 - - v.BackX = int16(Get16(buf[b:])) - b += 2 - - v.BackY = int16(Get16(buf[b:])) - b += 2 - - v.NumBackClipRects = Get32(buf[b:]) - b += 4 - - v.ClipRects = make([]Xf86driDrmClipRect, v.NumClipRects) - b += ReadXf86driDrmClipRectList(buf[b:], v.ClipRects) - - v.BackClipRects = make([]Xf86driDrmClipRect, v.NumBackClipRects) - b += ReadXf86driDrmClipRectList(buf[b:], v.BackClipRects) - - return v -} - -func (cook Xf86driGetDrawableInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driGetDrawableInfo -func (c *Conn) xf86driGetDrawableInfoRequest(Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 9 // 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 - - Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// Request Xf86driGetDeviceInfo -// size: 8 -type Xf86driGetDeviceInfoCookie struct { - *cookie -} - -func (c *Conn) Xf86driGetDeviceInfo(Screen uint32) Xf86driGetDeviceInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driGetDeviceInfoRequest(Screen), cookie) - return Xf86driGetDeviceInfoCookie{cookie} -} - -func (c *Conn) Xf86driGetDeviceInfoUnchecked(Screen uint32) Xf86driGetDeviceInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driGetDeviceInfoRequest(Screen), cookie) - return Xf86driGetDeviceInfoCookie{cookie} -} - -// Request reply for Xf86driGetDeviceInfo -// size: (32 + pad((int(DevicePrivateSize) * 4))) -type Xf86driGetDeviceInfoReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - FramebufferHandleLow uint32 - FramebufferHandleHigh uint32 - FramebufferOriginOffset uint32 - FramebufferSize uint32 - FramebufferStride uint32 - DevicePrivateSize uint32 - DevicePrivate []uint32 // size: pad((int(DevicePrivateSize) * 4)) -} - -// Waits and reads reply data from request Xf86driGetDeviceInfo -func (cook Xf86driGetDeviceInfoCookie) Reply() (*Xf86driGetDeviceInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driGetDeviceInfoReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driGetDeviceInfo -func xf86driGetDeviceInfoReply(buf []byte) *Xf86driGetDeviceInfoReply { - v := new(Xf86driGetDeviceInfoReply) - 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.FramebufferHandleLow = Get32(buf[b:]) - b += 4 - - v.FramebufferHandleHigh = Get32(buf[b:]) - b += 4 - - v.FramebufferOriginOffset = Get32(buf[b:]) - b += 4 - - v.FramebufferSize = Get32(buf[b:]) - b += 4 - - v.FramebufferStride = Get32(buf[b:]) - b += 4 - - v.DevicePrivateSize = Get32(buf[b:]) - b += 4 - - v.DevicePrivate = make([]uint32, v.DevicePrivateSize) - for i := 0; i < int(v.DevicePrivateSize); i++ { - v.DevicePrivate[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook Xf86driGetDeviceInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driGetDeviceInfo -func (c *Conn) xf86driGetDeviceInfoRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 10 // 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 Xf86driAuthConnection -// size: 12 -type Xf86driAuthConnectionCookie struct { - *cookie -} - -func (c *Conn) Xf86driAuthConnection(Screen uint32, Magic uint32) Xf86driAuthConnectionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driAuthConnectionRequest(Screen, Magic), cookie) - return Xf86driAuthConnectionCookie{cookie} -} - -func (c *Conn) Xf86driAuthConnectionUnchecked(Screen uint32, Magic uint32) Xf86driAuthConnectionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driAuthConnectionRequest(Screen, Magic), cookie) - return Xf86driAuthConnectionCookie{cookie} -} - -// Request reply for Xf86driAuthConnection -// size: 12 -type Xf86driAuthConnectionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Authenticated uint32 -} - -// Waits and reads reply data from request Xf86driAuthConnection -func (cook Xf86driAuthConnectionCookie) Reply() (*Xf86driAuthConnectionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driAuthConnectionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driAuthConnection -func xf86driAuthConnectionReply(buf []byte) *Xf86driAuthConnectionReply { - v := new(Xf86driAuthConnectionReply) - 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.Authenticated = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driAuthConnectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driAuthConnection -func (c *Conn) xf86driAuthConnectionRequest(Screen uint32, Magic uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 11 // 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 - - Put32(buf[b:], Magic) - b += 4 - - return buf -} diff --git a/nexgb/auto_xf86vidmode.go b/nexgb/auto_xf86vidmode.go deleted file mode 100644 index 983c021..0000000 --- a/nexgb/auto_xf86vidmode.go +++ /dev/null @@ -1,2398 +0,0 @@ -package xgb - -/* - This file was generated by xf86vidmode.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Xf86vidmodeInit must be called before using the XFree86-VidModeExtension extension. -func (c *Conn) Xf86vidmodeInit() error { - reply, err := c.QueryExtension(24, "XFree86-VidModeExtension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XFree86-VidModeExtension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XFree86-VidModeExtension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XFree86-VidModeExtension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XFree86-VidModeExtension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XFree86-VidModeExtension"] = make(map[int]newEventFun) - newExtErrorFuncs["XFree86-VidModeExtension"] = 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' - -const ( - Xf86vidmodeModeFlagPositiveHsync = 1 - Xf86vidmodeModeFlagNegativeHsync = 2 - Xf86vidmodeModeFlagPositiveVsync = 4 - Xf86vidmodeModeFlagNegativeVsync = 8 - Xf86vidmodeModeFlagInterlace = 16 - Xf86vidmodeModeFlagCompositeSync = 32 - Xf86vidmodeModeFlagPositiveCsync = 64 - Xf86vidmodeModeFlagNegativeCsync = 128 - Xf86vidmodeModeFlagHSkew = 256 - Xf86vidmodeModeFlagBroadcast = 512 - Xf86vidmodeModeFlagPixmux = 1024 - Xf86vidmodeModeFlagDoubleClock = 2048 - Xf86vidmodeModeFlagHalfClock = 4096 -) - -const ( - Xf86vidmodeClockFlagProgramable = 1 -) - -const ( - Xf86vidmodePermissionRead = 1 - Xf86vidmodePermissionWrite = 2 -) - -type Xf86vidmodeSyncrange uint32 - -type Xf86vidmodeDotclock uint32 - -// 'Xf86vidmodeModeInfo' struct definition -// Size: 48 -type Xf86vidmodeModeInfo struct { - Dotclock Xf86vidmodeDotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint32 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 4 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 -} - -// Struct read Xf86vidmodeModeInfo -func ReadXf86vidmodeModeInfo(buf []byte, v *Xf86vidmodeModeInfo) int { - b := 0 - - v.Dotclock = Xf86vidmodeDotclock(Get32(buf[b:])) - b += 4 - - v.Hdisplay = Get16(buf[b:]) - b += 2 - - v.Hsyncstart = Get16(buf[b:]) - b += 2 - - v.Hsyncend = Get16(buf[b:]) - b += 2 - - v.Htotal = Get16(buf[b:]) - b += 2 - - v.Hskew = Get32(buf[b:]) - b += 4 - - v.Vdisplay = Get16(buf[b:]) - b += 2 - - v.Vsyncstart = Get16(buf[b:]) - b += 2 - - v.Vsyncend = Get16(buf[b:]) - b += 2 - - v.Vtotal = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Flags = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Privsize = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Xf86vidmodeModeInfo -func ReadXf86vidmodeModeInfoList(buf []byte, dest []Xf86vidmodeModeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Xf86vidmodeModeInfo{} - b += ReadXf86vidmodeModeInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Xf86vidmodeModeInfo -func (v Xf86vidmodeModeInfo) Bytes() []byte { - buf := make([]byte, 48) - b := 0 - - Put32(buf[b:], uint32(v.Dotclock)) - b += 4 - - Put16(buf[b:], v.Hdisplay) - b += 2 - - Put16(buf[b:], v.Hsyncstart) - b += 2 - - Put16(buf[b:], v.Hsyncend) - b += 2 - - Put16(buf[b:], v.Htotal) - b += 2 - - Put32(buf[b:], v.Hskew) - b += 4 - - Put16(buf[b:], v.Vdisplay) - b += 2 - - Put16(buf[b:], v.Vsyncstart) - b += 2 - - Put16(buf[b:], v.Vsyncend) - b += 2 - - Put16(buf[b:], v.Vtotal) - b += 2 - - b += 4 // padding - - Put32(buf[b:], v.Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], v.Privsize) - b += 4 - - return buf -} - -// Write struct list Xf86vidmodeModeInfo -func Xf86vidmodeModeInfoListBytes(buf []byte, list []Xf86vidmodeModeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Error definition Xf86vidmodeBadClock (0) -// Size: 32 - -const BadXf86vidmodeBadClock = 0 - -type Xf86vidmodeBadClockError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeBadClock -func NewXf86vidmodeBadClockError(buf []byte) Error { - v := Xf86vidmodeBadClockError{} - v.NiceName = "Xf86vidmodeBadClock" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeBadClockError) ImplementsError() {} - -func (err Xf86vidmodeBadClockError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeBadClockError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeBadClockError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeBadClock {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][0] = NewXf86vidmodeBadClockError -} - -// Error definition Xf86vidmodeBadHTimings (1) -// Size: 32 - -const BadXf86vidmodeBadHTimings = 1 - -type Xf86vidmodeBadHTimingsError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeBadHTimings -func NewXf86vidmodeBadHTimingsError(buf []byte) Error { - v := Xf86vidmodeBadHTimingsError{} - v.NiceName = "Xf86vidmodeBadHTimings" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeBadHTimingsError) ImplementsError() {} - -func (err Xf86vidmodeBadHTimingsError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeBadHTimingsError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeBadHTimingsError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeBadHTimings {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][1] = NewXf86vidmodeBadHTimingsError -} - -// Error definition Xf86vidmodeBadVTimings (2) -// Size: 32 - -const BadXf86vidmodeBadVTimings = 2 - -type Xf86vidmodeBadVTimingsError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeBadVTimings -func NewXf86vidmodeBadVTimingsError(buf []byte) Error { - v := Xf86vidmodeBadVTimingsError{} - v.NiceName = "Xf86vidmodeBadVTimings" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeBadVTimingsError) ImplementsError() {} - -func (err Xf86vidmodeBadVTimingsError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeBadVTimingsError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeBadVTimingsError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeBadVTimings {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][2] = NewXf86vidmodeBadVTimingsError -} - -// Error definition Xf86vidmodeModeUnsuitable (3) -// Size: 32 - -const BadXf86vidmodeModeUnsuitable = 3 - -type Xf86vidmodeModeUnsuitableError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeModeUnsuitable -func NewXf86vidmodeModeUnsuitableError(buf []byte) Error { - v := Xf86vidmodeModeUnsuitableError{} - v.NiceName = "Xf86vidmodeModeUnsuitable" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeModeUnsuitableError) ImplementsError() {} - -func (err Xf86vidmodeModeUnsuitableError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeModeUnsuitableError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeModeUnsuitableError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeModeUnsuitable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][3] = NewXf86vidmodeModeUnsuitableError -} - -// Error definition Xf86vidmodeExtensionDisabled (4) -// Size: 32 - -const BadXf86vidmodeExtensionDisabled = 4 - -type Xf86vidmodeExtensionDisabledError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeExtensionDisabled -func NewXf86vidmodeExtensionDisabledError(buf []byte) Error { - v := Xf86vidmodeExtensionDisabledError{} - v.NiceName = "Xf86vidmodeExtensionDisabled" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeExtensionDisabledError) ImplementsError() {} - -func (err Xf86vidmodeExtensionDisabledError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeExtensionDisabledError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeExtensionDisabledError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeExtensionDisabled {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][4] = NewXf86vidmodeExtensionDisabledError -} - -// Error definition Xf86vidmodeClientNotLocal (5) -// Size: 32 - -const BadXf86vidmodeClientNotLocal = 5 - -type Xf86vidmodeClientNotLocalError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeClientNotLocal -func NewXf86vidmodeClientNotLocalError(buf []byte) Error { - v := Xf86vidmodeClientNotLocalError{} - v.NiceName = "Xf86vidmodeClientNotLocal" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeClientNotLocalError) ImplementsError() {} - -func (err Xf86vidmodeClientNotLocalError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeClientNotLocalError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeClientNotLocalError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeClientNotLocal {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][5] = NewXf86vidmodeClientNotLocalError -} - -// Error definition Xf86vidmodeZoomLocked (6) -// Size: 32 - -const BadXf86vidmodeZoomLocked = 6 - -type Xf86vidmodeZoomLockedError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeZoomLocked -func NewXf86vidmodeZoomLockedError(buf []byte) Error { - v := Xf86vidmodeZoomLockedError{} - v.NiceName = "Xf86vidmodeZoomLocked" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeZoomLockedError) ImplementsError() {} - -func (err Xf86vidmodeZoomLockedError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeZoomLockedError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeZoomLockedError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeZoomLocked {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][6] = NewXf86vidmodeZoomLockedError -} - -// Request Xf86vidmodeQueryVersion -// size: 4 -type Xf86vidmodeQueryVersionCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeQueryVersion() Xf86vidmodeQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeQueryVersionRequest(), cookie) - return Xf86vidmodeQueryVersionCookie{cookie} -} - -func (c *Conn) Xf86vidmodeQueryVersionUnchecked() Xf86vidmodeQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeQueryVersionRequest(), cookie) - return Xf86vidmodeQueryVersionCookie{cookie} -} - -// Request reply for Xf86vidmodeQueryVersion -// size: 12 -type Xf86vidmodeQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request Xf86vidmodeQueryVersion -func (cook Xf86vidmodeQueryVersionCookie) Reply() (*Xf86vidmodeQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeQueryVersion -func xf86vidmodeQueryVersionReply(buf []byte) *Xf86vidmodeQueryVersionReply { - v := new(Xf86vidmodeQueryVersionReply) - 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 Xf86vidmodeQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeQueryVersion -func (c *Conn) xf86vidmodeQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - 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 Xf86vidmodeGetModeLine -// size: 8 -type Xf86vidmodeGetModeLineCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetModeLine(Screen uint16) Xf86vidmodeGetModeLineCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetModeLineRequest(Screen), cookie) - return Xf86vidmodeGetModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetModeLineUnchecked(Screen uint16) Xf86vidmodeGetModeLineCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetModeLineRequest(Screen), cookie) - return Xf86vidmodeGetModeLineCookie{cookie} -} - -// Request reply for Xf86vidmodeGetModeLine -// size: (52 + pad((int(Privsize) * 1))) -type Xf86vidmodeGetModeLineReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Dotclock Xf86vidmodeDotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint16 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 2 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 - Private []byte // size: pad((int(Privsize) * 1)) -} - -// Waits and reads reply data from request Xf86vidmodeGetModeLine -func (cook Xf86vidmodeGetModeLineCookie) Reply() (*Xf86vidmodeGetModeLineReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetModeLineReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetModeLine -func xf86vidmodeGetModeLineReply(buf []byte) *Xf86vidmodeGetModeLineReply { - v := new(Xf86vidmodeGetModeLineReply) - 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.Dotclock = Xf86vidmodeDotclock(Get32(buf[b:])) - b += 4 - - v.Hdisplay = Get16(buf[b:]) - b += 2 - - v.Hsyncstart = Get16(buf[b:]) - b += 2 - - v.Hsyncend = Get16(buf[b:]) - b += 2 - - v.Htotal = Get16(buf[b:]) - b += 2 - - v.Hskew = Get16(buf[b:]) - b += 2 - - v.Vdisplay = Get16(buf[b:]) - b += 2 - - v.Vsyncstart = Get16(buf[b:]) - b += 2 - - v.Vsyncend = Get16(buf[b:]) - b += 2 - - v.Vtotal = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Flags = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Privsize = Get32(buf[b:]) - b += 4 - - v.Private = make([]byte, v.Privsize) - copy(v.Private[:v.Privsize], buf[b:]) - b += pad(int(v.Privsize)) - - return v -} - -func (cook Xf86vidmodeGetModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetModeLine -func (c *Conn) xf86vidmodeGetModeLineRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeModModeLine -// size: pad((48 + pad((int(Privsize) * 1)))) -type Xf86vidmodeModModeLineCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeModModeLine -func (c *Conn) Xf86vidmodeModModeLine(Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeModModeLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeModModeLineRequest(Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeModModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeModModeLineChecked(Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeModModeLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeModModeLineRequest(Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeModModeLineCookie{cookie} -} - -func (cook Xf86vidmodeModModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeModModeLine -func (c *Conn) xf86vidmodeModModeLineRequest(Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((48 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - 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:], Screen) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeSwitchMode -// size: 8 -type Xf86vidmodeSwitchModeCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSwitchMode -func (c *Conn) Xf86vidmodeSwitchMode(Screen uint16, Zoom uint16) Xf86vidmodeSwitchModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSwitchModeRequest(Screen, Zoom), cookie) - return Xf86vidmodeSwitchModeCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSwitchModeChecked(Screen uint16, Zoom uint16) Xf86vidmodeSwitchModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSwitchModeRequest(Screen, Zoom), cookie) - return Xf86vidmodeSwitchModeCookie{cookie} -} - -func (cook Xf86vidmodeSwitchModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSwitchMode -func (c *Conn) xf86vidmodeSwitchModeRequest(Screen uint16, Zoom uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - 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:], Screen) - b += 2 - - Put16(buf[b:], Zoom) - b += 2 - - return buf -} - -// Request Xf86vidmodeGetMonitor -// size: 8 -type Xf86vidmodeGetMonitorCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetMonitor(Screen uint16) Xf86vidmodeGetMonitorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetMonitorRequest(Screen), cookie) - return Xf86vidmodeGetMonitorCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetMonitorUnchecked(Screen uint16) Xf86vidmodeGetMonitorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetMonitorRequest(Screen), cookie) - return Xf86vidmodeGetMonitorCookie{cookie} -} - -// Request reply for Xf86vidmodeGetMonitor -// size: (((((32 + pad((int(NumHsync) * 4))) + pad((int(NumVsync) * 4))) + pad((int(VendorLength) * 1))) + pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))) + pad((int(ModelLength) * 1))) -type Xf86vidmodeGetMonitorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - VendorLength byte - ModelLength byte - NumHsync byte - NumVsync byte - // padding: 20 bytes - Hsync []Xf86vidmodeSyncrange // size: pad((int(NumHsync) * 4)) - Vsync []Xf86vidmodeSyncrange // size: pad((int(NumVsync) * 4)) - Vendor string // size: pad((int(VendorLength) * 1)) - AlignmentPad []byte // size: pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) - Model string // size: pad((int(ModelLength) * 1)) -} - -// Waits and reads reply data from request Xf86vidmodeGetMonitor -func (cook Xf86vidmodeGetMonitorCookie) Reply() (*Xf86vidmodeGetMonitorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetMonitorReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetMonitor -func xf86vidmodeGetMonitorReply(buf []byte) *Xf86vidmodeGetMonitorReply { - v := new(Xf86vidmodeGetMonitorReply) - 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.VendorLength = buf[b] - b += 1 - - v.ModelLength = buf[b] - b += 1 - - v.NumHsync = buf[b] - b += 1 - - v.NumVsync = buf[b] - b += 1 - - b += 20 // padding - - v.Hsync = make([]Xf86vidmodeSyncrange, v.NumHsync) - for i := 0; i < int(v.NumHsync); i++ { - v.Hsync[i] = Xf86vidmodeSyncrange(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Vsync = make([]Xf86vidmodeSyncrange, v.NumVsync) - for i := 0; i < int(v.NumVsync); i++ { - v.Vsync[i] = Xf86vidmodeSyncrange(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - { - byteString := make([]byte, v.VendorLength) - copy(byteString[:v.VendorLength], buf[b:]) - v.Vendor = string(byteString) - b += pad(int(v.VendorLength)) - } - - v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) - copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) - b += pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) - - { - byteString := make([]byte, v.ModelLength) - copy(byteString[:v.ModelLength], buf[b:]) - v.Model = string(byteString) - b += pad(int(v.ModelLength)) - } - - return v -} - -func (cook Xf86vidmodeGetMonitorCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetMonitor -func (c *Conn) xf86vidmodeGetMonitorRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeLockModeSwitch -// size: 8 -type Xf86vidmodeLockModeSwitchCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeLockModeSwitch -func (c *Conn) Xf86vidmodeLockModeSwitch(Screen uint16, Lock uint16) Xf86vidmodeLockModeSwitchCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeLockModeSwitchRequest(Screen, Lock), cookie) - return Xf86vidmodeLockModeSwitchCookie{cookie} -} - -func (c *Conn) Xf86vidmodeLockModeSwitchChecked(Screen uint16, Lock uint16) Xf86vidmodeLockModeSwitchCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeLockModeSwitchRequest(Screen, Lock), cookie) - return Xf86vidmodeLockModeSwitchCookie{cookie} -} - -func (cook Xf86vidmodeLockModeSwitchCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeLockModeSwitch -func (c *Conn) xf86vidmodeLockModeSwitchRequest(Screen uint16, Lock uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Lock) - b += 2 - - return buf -} - -// Request Xf86vidmodeGetAllModeLines -// size: 8 -type Xf86vidmodeGetAllModeLinesCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetAllModeLines(Screen uint16) Xf86vidmodeGetAllModeLinesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetAllModeLinesRequest(Screen), cookie) - return Xf86vidmodeGetAllModeLinesCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetAllModeLinesUnchecked(Screen uint16) Xf86vidmodeGetAllModeLinesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetAllModeLinesRequest(Screen), cookie) - return Xf86vidmodeGetAllModeLinesCookie{cookie} -} - -// Request reply for Xf86vidmodeGetAllModeLines -// size: (32 + pad((int(Modecount) * 48))) -type Xf86vidmodeGetAllModeLinesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Modecount uint32 - // padding: 20 bytes - Modeinfo []Xf86vidmodeModeInfo // size: pad((int(Modecount) * 48)) -} - -// Waits and reads reply data from request Xf86vidmodeGetAllModeLines -func (cook Xf86vidmodeGetAllModeLinesCookie) Reply() (*Xf86vidmodeGetAllModeLinesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetAllModeLinesReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetAllModeLines -func xf86vidmodeGetAllModeLinesReply(buf []byte) *Xf86vidmodeGetAllModeLinesReply { - v := new(Xf86vidmodeGetAllModeLinesReply) - 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.Modecount = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Modeinfo = make([]Xf86vidmodeModeInfo, v.Modecount) - b += ReadXf86vidmodeModeInfoList(buf[b:], v.Modeinfo) - - return v -} - -func (cook Xf86vidmodeGetAllModeLinesCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetAllModeLines -func (c *Conn) xf86vidmodeGetAllModeLinesRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - 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:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeAddModeLine -// size: pad((92 + pad((int(Privsize) * 1)))) -type Xf86vidmodeAddModeLineCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeAddModeLine -func (c *Conn) Xf86vidmodeAddModeLine(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Xf86vidmodeDotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) Xf86vidmodeAddModeLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeAddModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) - return Xf86vidmodeAddModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeAddModeLineChecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Xf86vidmodeDotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) Xf86vidmodeAddModeLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeAddModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) - return Xf86vidmodeAddModeLineCookie{cookie} -} - -func (cook Xf86vidmodeAddModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeAddModeLine -func (c *Conn) xf86vidmodeAddModeLineRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Xf86vidmodeDotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { - size := pad((92 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - 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:], Screen) - b += 4 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - Put32(buf[b:], uint32(AfterDotclock)) - b += 4 - - Put16(buf[b:], AfterHdisplay) - b += 2 - - Put16(buf[b:], AfterHsyncstart) - b += 2 - - Put16(buf[b:], AfterHsyncend) - b += 2 - - Put16(buf[b:], AfterHtotal) - b += 2 - - Put16(buf[b:], AfterHskew) - b += 2 - - Put16(buf[b:], AfterVdisplay) - b += 2 - - Put16(buf[b:], AfterVsyncstart) - b += 2 - - Put16(buf[b:], AfterVsyncend) - b += 2 - - Put16(buf[b:], AfterVtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], AfterFlags) - b += 4 - - b += 12 // padding - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeDeleteModeLine -// size: pad((52 + pad((int(Privsize) * 1)))) -type Xf86vidmodeDeleteModeLineCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeDeleteModeLine -func (c *Conn) Xf86vidmodeDeleteModeLine(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeDeleteModeLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeDeleteModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeDeleteModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeDeleteModeLineChecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeDeleteModeLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeDeleteModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeDeleteModeLineCookie{cookie} -} - -func (cook Xf86vidmodeDeleteModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeDeleteModeLine -func (c *Conn) xf86vidmodeDeleteModeLineRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((52 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - 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:], Screen) - b += 4 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeValidateModeLine -// size: pad((52 + pad((int(Privsize) * 1)))) -type Xf86vidmodeValidateModeLineCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeValidateModeLine(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeValidateModeLineCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeValidateModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeValidateModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeValidateModeLineUnchecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeValidateModeLineCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeValidateModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeValidateModeLineCookie{cookie} -} - -// Request reply for Xf86vidmodeValidateModeLine -// size: 32 -type Xf86vidmodeValidateModeLineReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status uint32 - // padding: 20 bytes -} - -// Waits and reads reply data from request Xf86vidmodeValidateModeLine -func (cook Xf86vidmodeValidateModeLineCookie) Reply() (*Xf86vidmodeValidateModeLineReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeValidateModeLineReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeValidateModeLine -func xf86vidmodeValidateModeLineReply(buf []byte) *Xf86vidmodeValidateModeLineReply { - v := new(Xf86vidmodeValidateModeLineReply) - 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.Status = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - return v -} - -func (cook Xf86vidmodeValidateModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeValidateModeLine -func (c *Conn) xf86vidmodeValidateModeLineRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((52 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 9 // 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 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeSwitchToMode -// size: pad((52 + pad((int(Privsize) * 1)))) -type Xf86vidmodeSwitchToModeCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSwitchToMode -func (c *Conn) Xf86vidmodeSwitchToMode(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeSwitchToModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSwitchToModeRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeSwitchToModeCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSwitchToModeChecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeSwitchToModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSwitchToModeRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeSwitchToModeCookie{cookie} -} - -func (cook Xf86vidmodeSwitchToModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSwitchToMode -func (c *Conn) xf86vidmodeSwitchToModeRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((52 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 10 // 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 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeGetViewPort -// size: 8 -type Xf86vidmodeGetViewPortCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetViewPort(Screen uint16) Xf86vidmodeGetViewPortCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetViewPortRequest(Screen), cookie) - return Xf86vidmodeGetViewPortCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetViewPortUnchecked(Screen uint16) Xf86vidmodeGetViewPortCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetViewPortRequest(Screen), cookie) - return Xf86vidmodeGetViewPortCookie{cookie} -} - -// Request reply for Xf86vidmodeGetViewPort -// size: 32 -type Xf86vidmodeGetViewPortReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - X uint32 - Y uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetViewPort -func (cook Xf86vidmodeGetViewPortCookie) Reply() (*Xf86vidmodeGetViewPortReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetViewPortReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetViewPort -func xf86vidmodeGetViewPortReply(buf []byte) *Xf86vidmodeGetViewPortReply { - v := new(Xf86vidmodeGetViewPortReply) - 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.X = Get32(buf[b:]) - b += 4 - - v.Y = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook Xf86vidmodeGetViewPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetViewPort -func (c *Conn) xf86vidmodeGetViewPortRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeSetViewPort -// size: 16 -type Xf86vidmodeSetViewPortCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetViewPort -func (c *Conn) Xf86vidmodeSetViewPort(Screen uint16, X uint32, Y uint32) Xf86vidmodeSetViewPortCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetViewPortRequest(Screen, X, Y), cookie) - return Xf86vidmodeSetViewPortCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetViewPortChecked(Screen uint16, X uint32, Y uint32) Xf86vidmodeSetViewPortCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetViewPortRequest(Screen, X, Y), cookie) - return Xf86vidmodeSetViewPortCookie{cookie} -} - -func (cook Xf86vidmodeSetViewPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetViewPort -func (c *Conn) xf86vidmodeSetViewPortRequest(Screen uint16, X uint32, Y uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - Put32(buf[b:], X) - b += 4 - - Put32(buf[b:], Y) - b += 4 - - return buf -} - -// Request Xf86vidmodeGetDotClocks -// size: 8 -type Xf86vidmodeGetDotClocksCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetDotClocks(Screen uint16) Xf86vidmodeGetDotClocksCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetDotClocksRequest(Screen), cookie) - return Xf86vidmodeGetDotClocksCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetDotClocksUnchecked(Screen uint16) Xf86vidmodeGetDotClocksCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetDotClocksRequest(Screen), cookie) - return Xf86vidmodeGetDotClocksCookie{cookie} -} - -// Request reply for Xf86vidmodeGetDotClocks -// size: (32 + pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4))) -type Xf86vidmodeGetDotClocksReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Flags uint32 - Clocks uint32 - Maxclocks uint32 - // padding: 12 bytes - Clock []uint32 // size: pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) -} - -// Waits and reads reply data from request Xf86vidmodeGetDotClocks -func (cook Xf86vidmodeGetDotClocksCookie) Reply() (*Xf86vidmodeGetDotClocksReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetDotClocksReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetDotClocks -func xf86vidmodeGetDotClocksReply(buf []byte) *Xf86vidmodeGetDotClocksReply { - v := new(Xf86vidmodeGetDotClocksReply) - 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.Flags = Get32(buf[b:]) - b += 4 - - v.Clocks = Get32(buf[b:]) - b += 4 - - v.Maxclocks = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Clock = make([]uint32, ((1 - (int(v.Flags) & 1)) * int(v.Clocks))) - for i := 0; i < int(((1 - (int(v.Flags) & 1)) * int(v.Clocks))); i++ { - v.Clock[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook Xf86vidmodeGetDotClocksCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetDotClocks -func (c *Conn) xf86vidmodeGetDotClocksRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeSetClientVersion -// size: 8 -type Xf86vidmodeSetClientVersionCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetClientVersion -func (c *Conn) Xf86vidmodeSetClientVersion(Major uint16, Minor uint16) Xf86vidmodeSetClientVersionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetClientVersionRequest(Major, Minor), cookie) - return Xf86vidmodeSetClientVersionCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetClientVersionChecked(Major uint16, Minor uint16) Xf86vidmodeSetClientVersionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetClientVersionRequest(Major, Minor), cookie) - return Xf86vidmodeSetClientVersionCookie{cookie} -} - -func (cook Xf86vidmodeSetClientVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetClientVersion -func (c *Conn) xf86vidmodeSetClientVersionRequest(Major uint16, Minor uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Major) - b += 2 - - Put16(buf[b:], Minor) - b += 2 - - return buf -} - -// Request Xf86vidmodeSetGamma -// size: 32 -type Xf86vidmodeSetGammaCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetGamma -func (c *Conn) Xf86vidmodeSetGamma(Screen uint16, Red uint32, Green uint32, Blue uint32) Xf86vidmodeSetGammaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetGammaRequest(Screen, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetGammaChecked(Screen uint16, Red uint32, Green uint32, Blue uint32) Xf86vidmodeSetGammaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetGammaRequest(Screen, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaCookie{cookie} -} - -func (cook Xf86vidmodeSetGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetGamma -func (c *Conn) xf86vidmodeSetGammaRequest(Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Red) - b += 4 - - Put32(buf[b:], Green) - b += 4 - - Put32(buf[b:], Blue) - b += 4 - - b += 12 // padding - - return buf -} - -// Request Xf86vidmodeGetGamma -// size: 32 -type Xf86vidmodeGetGammaCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetGamma(Screen uint16) Xf86vidmodeGetGammaCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetGammaRequest(Screen), cookie) - return Xf86vidmodeGetGammaCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetGammaUnchecked(Screen uint16) Xf86vidmodeGetGammaCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetGammaRequest(Screen), cookie) - return Xf86vidmodeGetGammaCookie{cookie} -} - -// Request reply for Xf86vidmodeGetGamma -// size: 32 -type Xf86vidmodeGetGammaReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Red uint32 - Green uint32 - Blue uint32 - // padding: 12 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetGamma -func (cook Xf86vidmodeGetGammaCookie) Reply() (*Xf86vidmodeGetGammaReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetGammaReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetGamma -func xf86vidmodeGetGammaReply(buf []byte) *Xf86vidmodeGetGammaReply { - v := new(Xf86vidmodeGetGammaReply) - 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.Red = Get32(buf[b:]) - b += 4 - - v.Green = Get32(buf[b:]) - b += 4 - - v.Blue = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - return v -} - -func (cook Xf86vidmodeGetGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetGamma -func (c *Conn) xf86vidmodeGetGammaRequest(Screen uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 26 // padding - - return buf -} - -// Request Xf86vidmodeGetGammaRamp -// size: 8 -type Xf86vidmodeGetGammaRampCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetGammaRamp(Screen uint16, Size uint16) Xf86vidmodeGetGammaRampCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetGammaRampRequest(Screen, Size), cookie) - return Xf86vidmodeGetGammaRampCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetGammaRampUnchecked(Screen uint16, Size uint16) Xf86vidmodeGetGammaRampCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetGammaRampRequest(Screen, Size), cookie) - return Xf86vidmodeGetGammaRampCookie{cookie} -} - -// Request reply for Xf86vidmodeGetGammaRamp -// size: (((32 + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) -type Xf86vidmodeGetGammaRampReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes - Red []uint16 // size: pad((((int(Size) + 1) & -2) * 2)) - Green []uint16 // size: pad((((int(Size) + 1) & -2) * 2)) - Blue []uint16 // size: pad((((int(Size) + 1) & -2) * 2)) -} - -// Waits and reads reply data from request Xf86vidmodeGetGammaRamp -func (cook Xf86vidmodeGetGammaRampCookie) Reply() (*Xf86vidmodeGetGammaRampReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetGammaRampReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetGammaRamp -func xf86vidmodeGetGammaRampReply(buf []byte) *Xf86vidmodeGetGammaRampReply { - v := new(Xf86vidmodeGetGammaRampReply) - 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.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Red = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Red[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Green[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Blue[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return v -} - -func (cook Xf86vidmodeGetGammaRampCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetGammaRamp -func (c *Conn) xf86vidmodeGetGammaRampRequest(Screen uint16, Size uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Size) - b += 2 - - return buf -} - -// Request Xf86vidmodeSetGammaRamp -// size: pad((((8 + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2)))) -type Xf86vidmodeSetGammaRampCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetGammaRamp -func (c *Conn) Xf86vidmodeSetGammaRamp(Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) Xf86vidmodeSetGammaRampCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetGammaRampRequest(Screen, Size, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaRampCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetGammaRampChecked(Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) Xf86vidmodeSetGammaRampCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetGammaRampRequest(Screen, Size, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaRampCookie{cookie} -} - -func (cook Xf86vidmodeSetGammaRampCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetGammaRamp -func (c *Conn) xf86vidmodeSetGammaRampRequest(Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { - size := pad((((8 + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Size) - b += 2 - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - Put16(buf[b:], Red[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - Put16(buf[b:], Green[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - Put16(buf[b:], Blue[i]) - b += 2 - } - b = pad(b) - - return buf -} - -// Request Xf86vidmodeGetGammaRampSize -// size: 8 -type Xf86vidmodeGetGammaRampSizeCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetGammaRampSize(Screen uint16) Xf86vidmodeGetGammaRampSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetGammaRampSizeRequest(Screen), cookie) - return Xf86vidmodeGetGammaRampSizeCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetGammaRampSizeUnchecked(Screen uint16) Xf86vidmodeGetGammaRampSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetGammaRampSizeRequest(Screen), cookie) - return Xf86vidmodeGetGammaRampSizeCookie{cookie} -} - -// Request reply for Xf86vidmodeGetGammaRampSize -// size: 32 -type Xf86vidmodeGetGammaRampSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetGammaRampSize -func (cook Xf86vidmodeGetGammaRampSizeCookie) Reply() (*Xf86vidmodeGetGammaRampSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetGammaRampSizeReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetGammaRampSize -func xf86vidmodeGetGammaRampSizeReply(buf []byte) *Xf86vidmodeGetGammaRampSizeReply { - v := new(Xf86vidmodeGetGammaRampSizeReply) - 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.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -func (cook Xf86vidmodeGetGammaRampSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetGammaRampSize -func (c *Conn) xf86vidmodeGetGammaRampSizeRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeGetPermissions -// size: 8 -type Xf86vidmodeGetPermissionsCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetPermissions(Screen uint16) Xf86vidmodeGetPermissionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetPermissionsRequest(Screen), cookie) - return Xf86vidmodeGetPermissionsCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetPermissionsUnchecked(Screen uint16) Xf86vidmodeGetPermissionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetPermissionsRequest(Screen), cookie) - return Xf86vidmodeGetPermissionsCookie{cookie} -} - -// Request reply for Xf86vidmodeGetPermissions -// size: 32 -type Xf86vidmodeGetPermissionsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Permissions uint32 - // padding: 20 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetPermissions -func (cook Xf86vidmodeGetPermissionsCookie) Reply() (*Xf86vidmodeGetPermissionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetPermissionsReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetPermissions -func xf86vidmodeGetPermissionsReply(buf []byte) *Xf86vidmodeGetPermissionsReply { - v := new(Xf86vidmodeGetPermissionsReply) - 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.Permissions = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - return v -} - -func (cook Xf86vidmodeGetPermissionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetPermissions -func (c *Conn) xf86vidmodeGetPermissionsRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} diff --git a/nexgb/auto_xfixes.go b/nexgb/auto_xfixes.go deleted file mode 100644 index 9284f6b..0000000 --- a/nexgb/auto_xfixes.go +++ /dev/null @@ -1,2173 +0,0 @@ -package xgb - -/* - This file was generated by xfixes.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" -// import "render" -// import "shape" - -// XfixesInit must be called before using the XFIXES extension. -func (c *Conn) XfixesInit() error { - reply, err := c.QueryExtension(6, "XFIXES").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XFIXES could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XFIXES"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XFIXES"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XFIXES"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XFIXES"] = make(map[int]newEventFun) - newExtErrorFuncs["XFIXES"] = make(map[int]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 ( - XfixesSaveSetModeInsert = 0 - XfixesSaveSetModeDelete = 1 -) - -const ( - XfixesSaveSetTargetNearest = 0 - XfixesSaveSetTargetRoot = 1 -) - -const ( - XfixesSaveSetMappingMap = 0 - XfixesSaveSetMappingUnmap = 1 -) - -const ( - XfixesSelectionEventSetSelectionOwner = 0 - XfixesSelectionEventSelectionWindowDestroy = 1 - XfixesSelectionEventSelectionClientClose = 2 -) - -const ( - XfixesSelectionEventMaskSetSelectionOwner = 1 - XfixesSelectionEventMaskSelectionWindowDestroy = 2 - XfixesSelectionEventMaskSelectionClientClose = 4 -) - -const ( - XfixesCursorNotifyDisplayCursor = 0 -) - -const ( - XfixesCursorNotifyMaskDisplayCursor = 1 -) - -const ( - XfixesRegionNone = 0 -) - -type XfixesRegion uint32 - -func (c *Conn) NewXfixesRegionId() (XfixesRegion, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XfixesRegion(id), nil -} - -// Event definition XfixesSelectionNotify (0) -// Size: 32 - -const XfixesSelectionNotify = 0 - -type XfixesSelectionNotifyEvent struct { - Sequence uint16 - Subtype byte - Window Window - Owner Window - Selection Atom - Timestamp Timestamp - SelectionTimestamp Timestamp - // padding: 8 bytes -} - -// Event read XfixesSelectionNotify -func NewXfixesSelectionNotifyEvent(buf []byte) Event { - v := XfixesSelectionNotifyEvent{} - b := 1 // don't read event number - - v.Subtype = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.SelectionTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - b += 8 // padding - - return v -} - -// Event write XfixesSelectionNotify -func (v XfixesSelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Subtype - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Owner)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.SelectionTimestamp)) - b += 4 - - b += 8 // padding - - return buf -} - -func (v XfixesSelectionNotifyEvent) ImplementsEvent() {} - -func (v XfixesSelectionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XfixesSelectionNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Subtype: %d", v.Subtype)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("SelectionTimestamp: %d", v.SelectionTimestamp)) - return "XfixesSelectionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XFIXES"][0] = NewXfixesSelectionNotifyEvent -} - -// Event definition XfixesCursorNotify (1) -// Size: 32 - -const XfixesCursorNotify = 1 - -type XfixesCursorNotifyEvent struct { - Sequence uint16 - Subtype byte - Window Window - CursorSerial uint32 - Timestamp Timestamp - Name Atom - // padding: 12 bytes -} - -// Event read XfixesCursorNotify -func NewXfixesCursorNotifyEvent(buf []byte) Event { - v := XfixesCursorNotifyEvent{} - b := 1 // don't read event number - - v.Subtype = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.CursorSerial = Get32(buf[b:]) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Name = Atom(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - return v -} - -// Event write XfixesCursorNotify -func (v XfixesCursorNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Subtype - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], v.CursorSerial) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Name)) - b += 4 - - b += 12 // padding - - return buf -} - -func (v XfixesCursorNotifyEvent) ImplementsEvent() {} - -func (v XfixesCursorNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XfixesCursorNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Subtype: %d", v.Subtype)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("CursorSerial: %d", v.CursorSerial)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("Name: %d", v.Name)) - return "XfixesCursorNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XFIXES"][1] = NewXfixesCursorNotifyEvent -} - -// Error definition XfixesBadRegion (0) -// Size: 32 - -const BadXfixesBadRegion = 0 - -type XfixesBadRegionError struct { - Sequence uint16 - NiceName string -} - -// Error read XfixesBadRegion -func NewXfixesBadRegionError(buf []byte) Error { - v := XfixesBadRegionError{} - v.NiceName = "XfixesBadRegion" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XfixesBadRegionError) ImplementsError() {} - -func (err XfixesBadRegionError) SequenceId() uint16 { - return err.Sequence -} - -func (err XfixesBadRegionError) BadId() uint32 { - return 0 -} - -func (err XfixesBadRegionError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXfixesBadRegion {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFIXES"][0] = NewXfixesBadRegionError -} - -// Request XfixesQueryVersion -// size: 12 -type XfixesQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XfixesQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) XfixesQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return XfixesQueryVersionCookie{cookie} -} - -func (c *Conn) XfixesQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) XfixesQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return XfixesQueryVersionCookie{cookie} -} - -// Request reply for XfixesQueryVersion -// size: 32 -type XfixesQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request XfixesQueryVersion -func (cook XfixesQueryVersionCookie) Reply() (*XfixesQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XfixesQueryVersion -func xfixesQueryVersionReply(buf []byte) *XfixesQueryVersionReply { - v := new(XfixesQueryVersionReply) - 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 XfixesQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesQueryVersion -func (c *Conn) xfixesQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - 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 XfixesChangeSaveSet -// size: 12 -type XfixesChangeSaveSetCookie struct { - *cookie -} - -// Write request to wire for XfixesChangeSaveSet -func (c *Conn) XfixesChangeSaveSet(Mode byte, Target byte, Map byte, Window Window) XfixesChangeSaveSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesChangeSaveSetRequest(Mode, Target, Map, Window), cookie) - return XfixesChangeSaveSetCookie{cookie} -} - -func (c *Conn) XfixesChangeSaveSetChecked(Mode byte, Target byte, Map byte, Window Window) XfixesChangeSaveSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesChangeSaveSetRequest(Mode, Target, Map, Window), cookie) - return XfixesChangeSaveSetCookie{cookie} -} - -func (cook XfixesChangeSaveSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesChangeSaveSet -func (c *Conn) xfixesChangeSaveSetRequest(Mode byte, Target byte, Map byte, Window Window) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - 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] = Mode - b += 1 - - buf[b] = Target - b += 1 - - buf[b] = Map - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XfixesSelectSelectionInput -// size: 16 -type XfixesSelectSelectionInputCookie struct { - *cookie -} - -// Write request to wire for XfixesSelectSelectionInput -func (c *Conn) XfixesSelectSelectionInput(Window Window, Selection Atom, EventMask uint32) XfixesSelectSelectionInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSelectSelectionInputRequest(Window, Selection, EventMask), cookie) - return XfixesSelectSelectionInputCookie{cookie} -} - -func (c *Conn) XfixesSelectSelectionInputChecked(Window Window, Selection Atom, EventMask uint32) XfixesSelectSelectionInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSelectSelectionInputRequest(Window, Selection, EventMask), cookie) - return XfixesSelectSelectionInputCookie{cookie} -} - -func (cook XfixesSelectSelectionInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSelectSelectionInput -func (c *Conn) xfixesSelectSelectionInputRequest(Window Window, Selection Atom, EventMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - 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(Selection)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// Request XfixesSelectCursorInput -// size: 12 -type XfixesSelectCursorInputCookie struct { - *cookie -} - -// Write request to wire for XfixesSelectCursorInput -func (c *Conn) XfixesSelectCursorInput(Window Window, EventMask uint32) XfixesSelectCursorInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSelectCursorInputRequest(Window, EventMask), cookie) - return XfixesSelectCursorInputCookie{cookie} -} - -func (c *Conn) XfixesSelectCursorInputChecked(Window Window, EventMask uint32) XfixesSelectCursorInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSelectCursorInputRequest(Window, EventMask), cookie) - return XfixesSelectCursorInputCookie{cookie} -} - -func (cook XfixesSelectCursorInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSelectCursorInput -func (c *Conn) xfixesSelectCursorInputRequest(Window Window, EventMask uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - 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:], EventMask) - b += 4 - - return buf -} - -// Request XfixesGetCursorImage -// size: 4 -type XfixesGetCursorImageCookie struct { - *cookie -} - -func (c *Conn) XfixesGetCursorImage() XfixesGetCursorImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesGetCursorImageRequest(), cookie) - return XfixesGetCursorImageCookie{cookie} -} - -func (c *Conn) XfixesGetCursorImageUnchecked() XfixesGetCursorImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesGetCursorImageRequest(), cookie) - return XfixesGetCursorImageCookie{cookie} -} - -// Request reply for XfixesGetCursorImage -// size: (32 + pad(((int(Width) * int(Height)) * 4))) -type XfixesGetCursorImageReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - // padding: 8 bytes - CursorImage []uint32 // size: pad(((int(Width) * int(Height)) * 4)) -} - -// Waits and reads reply data from request XfixesGetCursorImage -func (cook XfixesGetCursorImageCookie) Reply() (*XfixesGetCursorImageReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesGetCursorImageReply(buf), nil -} - -// Read reply into structure from buffer for XfixesGetCursorImage -func xfixesGetCursorImageReply(buf []byte) *XfixesGetCursorImageReply { - v := new(XfixesGetCursorImageReply) - 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.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Xhot = Get16(buf[b:]) - b += 2 - - v.Yhot = Get16(buf[b:]) - b += 2 - - v.CursorSerial = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XfixesGetCursorImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesGetCursorImage -func (c *Conn) xfixesGetCursorImageRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - 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 XfixesCreateRegion -// size: pad((8 + pad((len(Rectangles) * 8)))) -type XfixesCreateRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegion -func (c *Conn) XfixesCreateRegion(Region XfixesRegion, Rectangles []Rectangle) XfixesCreateRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionRequest(Region, Rectangles), cookie) - return XfixesCreateRegionCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionChecked(Region XfixesRegion, Rectangles []Rectangle) XfixesCreateRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionRequest(Region, Rectangles), cookie) - return XfixesCreateRegionCookie{cookie} -} - -func (cook XfixesCreateRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegion -func (c *Conn) xfixesCreateRegionRequest(Region XfixesRegion, Rectangles []Rectangle) []byte { - size := pad((8 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - 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 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request XfixesCreateRegionFromBitmap -// size: 12 -type XfixesCreateRegionFromBitmapCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromBitmap -func (c *Conn) XfixesCreateRegionFromBitmap(Region XfixesRegion, Bitmap Pixmap) XfixesCreateRegionFromBitmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromBitmapRequest(Region, Bitmap), cookie) - return XfixesCreateRegionFromBitmapCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromBitmapChecked(Region XfixesRegion, Bitmap Pixmap) XfixesCreateRegionFromBitmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromBitmapRequest(Region, Bitmap), cookie) - return XfixesCreateRegionFromBitmapCookie{cookie} -} - -func (cook XfixesCreateRegionFromBitmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromBitmap -func (c *Conn) xfixesCreateRegionFromBitmapRequest(Region XfixesRegion, Bitmap Pixmap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - 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(Region)) - b += 4 - - Put32(buf[b:], uint32(Bitmap)) - b += 4 - - return buf -} - -// Request XfixesCreateRegionFromWindow -// size: 16 -type XfixesCreateRegionFromWindowCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromWindow -func (c *Conn) XfixesCreateRegionFromWindow(Region XfixesRegion, Window Window, Kind ShapeKind) XfixesCreateRegionFromWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromWindowRequest(Region, Window, Kind), cookie) - return XfixesCreateRegionFromWindowCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromWindowChecked(Region XfixesRegion, Window Window, Kind ShapeKind) XfixesCreateRegionFromWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromWindowRequest(Region, Window, Kind), cookie) - return XfixesCreateRegionFromWindowCookie{cookie} -} - -func (cook XfixesCreateRegionFromWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromWindow -func (c *Conn) xfixesCreateRegionFromWindowRequest(Region XfixesRegion, Window Window, Kind ShapeKind) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - 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(Region)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = byte(Kind) - b += 1 - - b += 3 // padding - - return buf -} - -// Request XfixesCreateRegionFromGC -// size: 12 -type XfixesCreateRegionFromGCCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromGC -func (c *Conn) XfixesCreateRegionFromGC(Region XfixesRegion, Gc Gcontext) XfixesCreateRegionFromGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromGCRequest(Region, Gc), cookie) - return XfixesCreateRegionFromGCCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromGCChecked(Region XfixesRegion, Gc Gcontext) XfixesCreateRegionFromGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromGCRequest(Region, Gc), cookie) - return XfixesCreateRegionFromGCCookie{cookie} -} - -func (cook XfixesCreateRegionFromGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromGC -func (c *Conn) xfixesCreateRegionFromGCRequest(Region XfixesRegion, Gc Gcontext) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - 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(Region)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - return buf -} - -// Request XfixesCreateRegionFromPicture -// size: 12 -type XfixesCreateRegionFromPictureCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromPicture -func (c *Conn) XfixesCreateRegionFromPicture(Region XfixesRegion, Picture RenderPicture) XfixesCreateRegionFromPictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromPictureRequest(Region, Picture), cookie) - return XfixesCreateRegionFromPictureCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromPictureChecked(Region XfixesRegion, Picture RenderPicture) XfixesCreateRegionFromPictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromPictureRequest(Region, Picture), cookie) - return XfixesCreateRegionFromPictureCookie{cookie} -} - -func (cook XfixesCreateRegionFromPictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromPicture -func (c *Conn) xfixesCreateRegionFromPictureRequest(Region XfixesRegion, Picture RenderPicture) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 9 // 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(Picture)) - b += 4 - - return buf -} - -// Request XfixesDestroyRegion -// size: 8 -type XfixesDestroyRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesDestroyRegion -func (c *Conn) XfixesDestroyRegion(Region XfixesRegion) XfixesDestroyRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesDestroyRegionRequest(Region), cookie) - return XfixesDestroyRegionCookie{cookie} -} - -func (c *Conn) XfixesDestroyRegionChecked(Region XfixesRegion) XfixesDestroyRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesDestroyRegionRequest(Region), cookie) - return XfixesDestroyRegionCookie{cookie} -} - -func (cook XfixesDestroyRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesDestroyRegion -func (c *Conn) xfixesDestroyRegionRequest(Region XfixesRegion) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 10 // 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 - - return buf -} - -// Request XfixesSetRegion -// size: pad((8 + pad((len(Rectangles) * 8)))) -type XfixesSetRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetRegion -func (c *Conn) XfixesSetRegion(Region XfixesRegion, Rectangles []Rectangle) XfixesSetRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetRegionRequest(Region, Rectangles), cookie) - return XfixesSetRegionCookie{cookie} -} - -func (c *Conn) XfixesSetRegionChecked(Region XfixesRegion, Rectangles []Rectangle) XfixesSetRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetRegionRequest(Region, Rectangles), cookie) - return XfixesSetRegionCookie{cookie} -} - -func (cook XfixesSetRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetRegion -func (c *Conn) xfixesSetRegionRequest(Region XfixesRegion, Rectangles []Rectangle) []byte { - size := pad((8 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 11 // 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 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request XfixesCopyRegion -// size: 12 -type XfixesCopyRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesCopyRegion -func (c *Conn) XfixesCopyRegion(Source XfixesRegion, Destination XfixesRegion) XfixesCopyRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCopyRegionRequest(Source, Destination), cookie) - return XfixesCopyRegionCookie{cookie} -} - -func (c *Conn) XfixesCopyRegionChecked(Source XfixesRegion, Destination XfixesRegion) XfixesCopyRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCopyRegionRequest(Source, Destination), cookie) - return XfixesCopyRegionCookie{cookie} -} - -func (cook XfixesCopyRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCopyRegion -func (c *Conn) xfixesCopyRegionRequest(Source XfixesRegion, Destination XfixesRegion) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesUnionRegion -// size: 16 -type XfixesUnionRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesUnionRegion -func (c *Conn) XfixesUnionRegion(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesUnionRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesUnionRegionRequest(Source1, Source2, Destination), cookie) - return XfixesUnionRegionCookie{cookie} -} - -func (c *Conn) XfixesUnionRegionChecked(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesUnionRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesUnionRegionRequest(Source1, Source2, Destination), cookie) - return XfixesUnionRegionCookie{cookie} -} - -func (cook XfixesUnionRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesUnionRegion -func (c *Conn) xfixesUnionRegionRequest(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source1)) - b += 4 - - Put32(buf[b:], uint32(Source2)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesIntersectRegion -// size: 16 -type XfixesIntersectRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesIntersectRegion -func (c *Conn) XfixesIntersectRegion(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesIntersectRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesIntersectRegionRequest(Source1, Source2, Destination), cookie) - return XfixesIntersectRegionCookie{cookie} -} - -func (c *Conn) XfixesIntersectRegionChecked(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesIntersectRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesIntersectRegionRequest(Source1, Source2, Destination), cookie) - return XfixesIntersectRegionCookie{cookie} -} - -func (cook XfixesIntersectRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesIntersectRegion -func (c *Conn) xfixesIntersectRegionRequest(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source1)) - b += 4 - - Put32(buf[b:], uint32(Source2)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesSubtractRegion -// size: 16 -type XfixesSubtractRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSubtractRegion -func (c *Conn) XfixesSubtractRegion(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesSubtractRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSubtractRegionRequest(Source1, Source2, Destination), cookie) - return XfixesSubtractRegionCookie{cookie} -} - -func (c *Conn) XfixesSubtractRegionChecked(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesSubtractRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSubtractRegionRequest(Source1, Source2, Destination), cookie) - return XfixesSubtractRegionCookie{cookie} -} - -func (cook XfixesSubtractRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSubtractRegion -func (c *Conn) xfixesSubtractRegionRequest(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source1)) - b += 4 - - Put32(buf[b:], uint32(Source2)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesInvertRegion -// size: 20 -type XfixesInvertRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesInvertRegion -func (c *Conn) XfixesInvertRegion(Source XfixesRegion, Bounds Rectangle, Destination XfixesRegion) XfixesInvertRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesInvertRegionRequest(Source, Bounds, Destination), cookie) - return XfixesInvertRegionCookie{cookie} -} - -func (c *Conn) XfixesInvertRegionChecked(Source XfixesRegion, Bounds Rectangle, Destination XfixesRegion) XfixesInvertRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesInvertRegionRequest(Source, Bounds, Destination), cookie) - return XfixesInvertRegionCookie{cookie} -} - -func (cook XfixesInvertRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesInvertRegion -func (c *Conn) xfixesInvertRegionRequest(Source XfixesRegion, Bounds Rectangle, Destination XfixesRegion) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - { - structBytes := Bounds.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesTranslateRegion -// size: 12 -type XfixesTranslateRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesTranslateRegion -func (c *Conn) XfixesTranslateRegion(Region XfixesRegion, Dx int16, Dy int16) XfixesTranslateRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesTranslateRegionRequest(Region, Dx, Dy), cookie) - return XfixesTranslateRegionCookie{cookie} -} - -func (c *Conn) XfixesTranslateRegionChecked(Region XfixesRegion, Dx int16, Dy int16) XfixesTranslateRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesTranslateRegionRequest(Region, Dx, Dy), cookie) - return XfixesTranslateRegionCookie{cookie} -} - -func (cook XfixesTranslateRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesTranslateRegion -func (c *Conn) xfixesTranslateRegionRequest(Region XfixesRegion, Dx int16, Dy int16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put16(buf[b:], uint16(Dx)) - b += 2 - - Put16(buf[b:], uint16(Dy)) - b += 2 - - return buf -} - -// Request XfixesRegionExtents -// size: 12 -type XfixesRegionExtentsCookie struct { - *cookie -} - -// Write request to wire for XfixesRegionExtents -func (c *Conn) XfixesRegionExtents(Source XfixesRegion, Destination XfixesRegion) XfixesRegionExtentsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesRegionExtentsRequest(Source, Destination), cookie) - return XfixesRegionExtentsCookie{cookie} -} - -func (c *Conn) XfixesRegionExtentsChecked(Source XfixesRegion, Destination XfixesRegion) XfixesRegionExtentsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesRegionExtentsRequest(Source, Destination), cookie) - return XfixesRegionExtentsCookie{cookie} -} - -func (cook XfixesRegionExtentsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesRegionExtents -func (c *Conn) xfixesRegionExtentsRequest(Source XfixesRegion, Destination XfixesRegion) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesFetchRegion -// size: 8 -type XfixesFetchRegionCookie struct { - *cookie -} - -func (c *Conn) XfixesFetchRegion(Region XfixesRegion) XfixesFetchRegionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesFetchRegionRequest(Region), cookie) - return XfixesFetchRegionCookie{cookie} -} - -func (c *Conn) XfixesFetchRegionUnchecked(Region XfixesRegion) XfixesFetchRegionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesFetchRegionRequest(Region), cookie) - return XfixesFetchRegionCookie{cookie} -} - -// Request reply for XfixesFetchRegion -// size: (32 + pad(((int(Length) / 2) * 8))) -type XfixesFetchRegionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Extents Rectangle - // padding: 16 bytes - Rectangles []Rectangle // size: pad(((int(Length) / 2) * 8)) -} - -// Waits and reads reply data from request XfixesFetchRegion -func (cook XfixesFetchRegionCookie) Reply() (*XfixesFetchRegionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesFetchRegionReply(buf), nil -} - -// Read reply into structure from buffer for XfixesFetchRegion -func xfixesFetchRegionReply(buf []byte) *XfixesFetchRegionReply { - v := new(XfixesFetchRegionReply) - 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.Extents = Rectangle{} - b += ReadRectangle(buf[b:], &v.Extents) - - b += 16 // padding - - v.Rectangles = make([]Rectangle, (int(v.Length) / 2)) - b += ReadRectangleList(buf[b:], v.Rectangles) - - return v -} - -func (cook XfixesFetchRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesFetchRegion -func (c *Conn) xfixesFetchRegionRequest(Region XfixesRegion) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 19 // 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 - - return buf -} - -// Request XfixesSetGCClipRegion -// size: 16 -type XfixesSetGCClipRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetGCClipRegion -func (c *Conn) XfixesSetGCClipRegion(Gc Gcontext, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetGCClipRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetGCClipRegionRequest(Gc, Region, XOrigin, YOrigin), cookie) - return XfixesSetGCClipRegionCookie{cookie} -} - -func (c *Conn) XfixesSetGCClipRegionChecked(Gc Gcontext, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetGCClipRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetGCClipRegionRequest(Gc, Region, XOrigin, YOrigin), cookie) - return XfixesSetGCClipRegionCookie{cookie} -} - -func (cook XfixesSetGCClipRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetGCClipRegion -func (c *Conn) xfixesSetGCClipRegionRequest(Gc Gcontext, Region XfixesRegion, XOrigin int16, YOrigin int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put16(buf[b:], uint16(XOrigin)) - b += 2 - - Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// Request XfixesSetWindowShapeRegion -// size: 20 -type XfixesSetWindowShapeRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetWindowShapeRegion -func (c *Conn) XfixesSetWindowShapeRegion(Dest Window, DestKind ShapeKind, XOffset int16, YOffset int16, Region XfixesRegion) XfixesSetWindowShapeRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetWindowShapeRegionRequest(Dest, DestKind, XOffset, YOffset, Region), cookie) - return XfixesSetWindowShapeRegionCookie{cookie} -} - -func (c *Conn) XfixesSetWindowShapeRegionChecked(Dest Window, DestKind ShapeKind, XOffset int16, YOffset int16, Region XfixesRegion) XfixesSetWindowShapeRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetWindowShapeRegionRequest(Dest, DestKind, XOffset, YOffset, Region), cookie) - return XfixesSetWindowShapeRegionCookie{cookie} -} - -func (cook XfixesSetWindowShapeRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetWindowShapeRegion -func (c *Conn) xfixesSetWindowShapeRegionRequest(Dest Window, DestKind ShapeKind, XOffset int16, YOffset int16, Region XfixesRegion) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Dest)) - b += 4 - - buf[b] = byte(DestKind) - b += 1 - - b += 3 // padding - - Put16(buf[b:], uint16(XOffset)) - b += 2 - - Put16(buf[b:], uint16(YOffset)) - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - return buf -} - -// Request XfixesSetPictureClipRegion -// size: 16 -type XfixesSetPictureClipRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetPictureClipRegion -func (c *Conn) XfixesSetPictureClipRegion(Picture RenderPicture, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetPictureClipRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetPictureClipRegionRequest(Picture, Region, XOrigin, YOrigin), cookie) - return XfixesSetPictureClipRegionCookie{cookie} -} - -func (c *Conn) XfixesSetPictureClipRegionChecked(Picture RenderPicture, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetPictureClipRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetPictureClipRegionRequest(Picture, Region, XOrigin, YOrigin), cookie) - return XfixesSetPictureClipRegionCookie{cookie} -} - -func (cook XfixesSetPictureClipRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetPictureClipRegion -func (c *Conn) xfixesSetPictureClipRegionRequest(Picture RenderPicture, Region XfixesRegion, XOrigin int16, YOrigin int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put16(buf[b:], uint16(XOrigin)) - b += 2 - - Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// Request XfixesSetCursorName -// size: pad((12 + pad((int(Nbytes) * 1)))) -type XfixesSetCursorNameCookie struct { - *cookie -} - -// Write request to wire for XfixesSetCursorName -func (c *Conn) XfixesSetCursorName(Cursor Cursor, Nbytes uint16, Name string) XfixesSetCursorNameCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetCursorNameRequest(Cursor, Nbytes, Name), cookie) - return XfixesSetCursorNameCookie{cookie} -} - -func (c *Conn) XfixesSetCursorNameChecked(Cursor Cursor, Nbytes uint16, Name string) XfixesSetCursorNameCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetCursorNameRequest(Cursor, Nbytes, Name), cookie) - return XfixesSetCursorNameCookie{cookie} -} - -func (cook XfixesSetCursorNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetCursorName -func (c *Conn) xfixesSetCursorNameRequest(Cursor Cursor, Nbytes uint16, Name string) []byte { - size := pad((12 + pad((int(Nbytes) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += pad(int(Nbytes)) - - return buf -} - -// Request XfixesGetCursorName -// size: 8 -type XfixesGetCursorNameCookie struct { - *cookie -} - -func (c *Conn) XfixesGetCursorName(Cursor Cursor) XfixesGetCursorNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesGetCursorNameRequest(Cursor), cookie) - return XfixesGetCursorNameCookie{cookie} -} - -func (c *Conn) XfixesGetCursorNameUnchecked(Cursor Cursor) XfixesGetCursorNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesGetCursorNameRequest(Cursor), cookie) - return XfixesGetCursorNameCookie{cookie} -} - -// Request reply for XfixesGetCursorName -// size: (32 + pad((int(Nbytes) * 1))) -type XfixesGetCursorNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Atom Atom - Nbytes uint16 - // padding: 18 bytes - Name string // size: pad((int(Nbytes) * 1)) -} - -// Waits and reads reply data from request XfixesGetCursorName -func (cook XfixesGetCursorNameCookie) Reply() (*XfixesGetCursorNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesGetCursorNameReply(buf), nil -} - -// Read reply into structure from buffer for XfixesGetCursorName -func xfixesGetCursorNameReply(buf []byte) *XfixesGetCursorNameReply { - v := new(XfixesGetCursorNameReply) - 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.Atom = Atom(Get32(buf[b:])) - b += 4 - - v.Nbytes = Get16(buf[b:]) - b += 2 - - b += 18 // padding - - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.Nbytes)) - } - - return v -} - -func (cook XfixesGetCursorNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesGetCursorName -func (c *Conn) xfixesGetCursorNameRequest(Cursor Cursor) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - return buf -} - -// Request XfixesGetCursorImageAndName -// size: 4 -type XfixesGetCursorImageAndNameCookie struct { - *cookie -} - -func (c *Conn) XfixesGetCursorImageAndName() XfixesGetCursorImageAndNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesGetCursorImageAndNameRequest(), cookie) - return XfixesGetCursorImageAndNameCookie{cookie} -} - -func (c *Conn) XfixesGetCursorImageAndNameUnchecked() XfixesGetCursorImageAndNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesGetCursorImageAndNameRequest(), cookie) - return XfixesGetCursorImageAndNameCookie{cookie} -} - -// Request reply for XfixesGetCursorImageAndName -// size: ((32 + pad((int(Nbytes) * 1))) + pad(((int(Width) * int(Height)) * 4))) -type XfixesGetCursorImageAndNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - CursorAtom Atom - Nbytes uint16 - // padding: 2 bytes - Name string // size: pad((int(Nbytes) * 1)) - CursorImage []uint32 // size: pad(((int(Width) * int(Height)) * 4)) -} - -// Waits and reads reply data from request XfixesGetCursorImageAndName -func (cook XfixesGetCursorImageAndNameCookie) Reply() (*XfixesGetCursorImageAndNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesGetCursorImageAndNameReply(buf), nil -} - -// Read reply into structure from buffer for XfixesGetCursorImageAndName -func xfixesGetCursorImageAndNameReply(buf []byte) *XfixesGetCursorImageAndNameReply { - v := new(XfixesGetCursorImageAndNameReply) - 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.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Xhot = Get16(buf[b:]) - b += 2 - - v.Yhot = Get16(buf[b:]) - b += 2 - - v.CursorSerial = Get32(buf[b:]) - b += 4 - - v.CursorAtom = Atom(Get32(buf[b:])) - b += 4 - - v.Nbytes = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.Nbytes)) - } - - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XfixesGetCursorImageAndNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesGetCursorImageAndName -func (c *Conn) xfixesGetCursorImageAndNameRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XfixesChangeCursor -// size: 12 -type XfixesChangeCursorCookie struct { - *cookie -} - -// Write request to wire for XfixesChangeCursor -func (c *Conn) XfixesChangeCursor(Source Cursor, Destination Cursor) XfixesChangeCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesChangeCursorRequest(Source, Destination), cookie) - return XfixesChangeCursorCookie{cookie} -} - -func (c *Conn) XfixesChangeCursorChecked(Source Cursor, Destination Cursor) XfixesChangeCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesChangeCursorRequest(Source, Destination), cookie) - return XfixesChangeCursorCookie{cookie} -} - -func (cook XfixesChangeCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesChangeCursor -func (c *Conn) xfixesChangeCursorRequest(Source Cursor, Destination Cursor) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesChangeCursorByName -// size: pad((12 + pad((int(Nbytes) * 1)))) -type XfixesChangeCursorByNameCookie struct { - *cookie -} - -// Write request to wire for XfixesChangeCursorByName -func (c *Conn) XfixesChangeCursorByName(Src Cursor, Nbytes uint16, Name string) XfixesChangeCursorByNameCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesChangeCursorByNameRequest(Src, Nbytes, Name), cookie) - return XfixesChangeCursorByNameCookie{cookie} -} - -func (c *Conn) XfixesChangeCursorByNameChecked(Src Cursor, Nbytes uint16, Name string) XfixesChangeCursorByNameCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesChangeCursorByNameRequest(Src, Nbytes, Name), cookie) - return XfixesChangeCursorByNameCookie{cookie} -} - -func (cook XfixesChangeCursorByNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesChangeCursorByName -func (c *Conn) xfixesChangeCursorByNameRequest(Src Cursor, Nbytes uint16, Name string) []byte { - size := pad((12 + pad((int(Nbytes) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += pad(int(Nbytes)) - - return buf -} - -// Request XfixesExpandRegion -// size: 20 -type XfixesExpandRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesExpandRegion -func (c *Conn) XfixesExpandRegion(Source XfixesRegion, Destination XfixesRegion, Left uint16, Right uint16, Top uint16, Bottom uint16) XfixesExpandRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesExpandRegionRequest(Source, Destination, Left, Right, Top, Bottom), cookie) - return XfixesExpandRegionCookie{cookie} -} - -func (c *Conn) XfixesExpandRegionChecked(Source XfixesRegion, Destination XfixesRegion, Left uint16, Right uint16, Top uint16, Bottom uint16) XfixesExpandRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesExpandRegionRequest(Source, Destination, Left, Right, Top, Bottom), cookie) - return XfixesExpandRegionCookie{cookie} -} - -func (cook XfixesExpandRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesExpandRegion -func (c *Conn) xfixesExpandRegionRequest(Source XfixesRegion, Destination XfixesRegion, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - Put16(buf[b:], Left) - b += 2 - - Put16(buf[b:], Right) - b += 2 - - Put16(buf[b:], Top) - b += 2 - - Put16(buf[b:], Bottom) - b += 2 - - return buf -} - -// Request XfixesHideCursor -// size: 8 -type XfixesHideCursorCookie struct { - *cookie -} - -// Write request to wire for XfixesHideCursor -func (c *Conn) XfixesHideCursor(Window Window) XfixesHideCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesHideCursorRequest(Window), cookie) - return XfixesHideCursorCookie{cookie} -} - -func (c *Conn) XfixesHideCursorChecked(Window Window) XfixesHideCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesHideCursorRequest(Window), cookie) - return XfixesHideCursorCookie{cookie} -} - -func (cook XfixesHideCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesHideCursor -func (c *Conn) xfixesHideCursorRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 29 // 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 XfixesShowCursor -// size: 8 -type XfixesShowCursorCookie struct { - *cookie -} - -// Write request to wire for XfixesShowCursor -func (c *Conn) XfixesShowCursor(Window Window) XfixesShowCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesShowCursorRequest(Window), cookie) - return XfixesShowCursorCookie{cookie} -} - -func (c *Conn) XfixesShowCursorChecked(Window Window) XfixesShowCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesShowCursorRequest(Window), cookie) - return XfixesShowCursorCookie{cookie} -} - -func (cook XfixesShowCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesShowCursor -func (c *Conn) xfixesShowCursorRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 30 // 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 -} diff --git a/nexgb/auto_xinerama.go b/nexgb/auto_xinerama.go deleted file mode 100644 index fc24ae3..0000000 --- a/nexgb/auto_xinerama.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_xinput.go b/nexgb/auto_xinput.go deleted file mode 100644 index 78142b6..0000000 --- a/nexgb/auto_xinput.go +++ /dev/null @@ -1,7297 +0,0 @@ -package xgb - -/* - This file was generated by xinput.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" - -// XinputInit must be called before using the XInputExtension extension. -func (c *Conn) XinputInit() error { - reply, err := c.QueryExtension(15, "XInputExtension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XInputExtension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XInputExtension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XInputExtension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XInputExtension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XInputExtension"] = make(map[int]newEventFun) - newExtErrorFuncs["XInputExtension"] = 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 ( - XinputValuatorModeRelative = 0 - XinputValuatorModeAbsolute = 1 -) - -const ( - XinputPropagateModeAddToList = 0 - XinputPropagateModeDeleteFromList = 1 -) - -const ( - XinputDeviceUseIsXPointer = 0 - XinputDeviceUseIsXKeyboard = 1 - XinputDeviceUseIsXExtensionDevice = 2 - XinputDeviceUseIsXExtensionKeyboard = 3 - XinputDeviceUseIsXExtensionPointer = 4 -) - -const ( - XinputInputClassKey = 0 - XinputInputClassButton = 1 - XinputInputClassValuator = 2 - XinputInputClassFeedback = 3 - XinputInputClassProximity = 4 - XinputInputClassFocus = 5 - XinputInputClassOther = 6 -) - -const ( - XinputDeviceInputModeAsyncThisDevice = 0 - XinputDeviceInputModeSyncThisDevice = 1 - XinputDeviceInputModeReplayThisDevice = 2 - XinputDeviceInputModeAsyncOtherDevices = 3 - XinputDeviceInputModeAsyncAll = 4 - XinputDeviceInputModeSyncAll = 5 -) - -const ( - XinputFeedbackClassKeyboard = 0 - XinputFeedbackClassPointer = 1 - XinputFeedbackClassString = 2 - XinputFeedbackClassInteger = 3 - XinputFeedbackClassLed = 4 - XinputFeedbackClassBell = 5 -) - -type XinputKeyCode byte - -type XinputEventClass uint32 - -// 'XinputDeviceInfo' struct definition -// Size: 8 -type XinputDeviceInfo struct { - DeviceType Atom - DeviceId byte - NumClassInfo byte - DeviceUse byte - // padding: 1 bytes -} - -// Struct read XinputDeviceInfo -func ReadXinputDeviceInfo(buf []byte, v *XinputDeviceInfo) int { - b := 0 - - v.DeviceType = Atom(Get32(buf[b:])) - b += 4 - - v.DeviceId = buf[b] - b += 1 - - v.NumClassInfo = buf[b] - b += 1 - - v.DeviceUse = buf[b] - b += 1 - - b += 1 // padding - - return b -} - -// Struct list read XinputDeviceInfo -func ReadXinputDeviceInfoList(buf []byte, dest []XinputDeviceInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceInfo{} - b += ReadXinputDeviceInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceInfo -func (v XinputDeviceInfo) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.DeviceType)) - b += 4 - - buf[b] = v.DeviceId - b += 1 - - buf[b] = v.NumClassInfo - b += 1 - - buf[b] = v.DeviceUse - b += 1 - - b += 1 // padding - - return buf -} - -// Write struct list XinputDeviceInfo -func XinputDeviceInfoListBytes(buf []byte, list []XinputDeviceInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputInputInfo' struct definition -// Size: 2 -type XinputInputInfo struct { - ClassId byte - Len byte -} - -// Struct read XinputInputInfo -func ReadXinputInputInfo(buf []byte, v *XinputInputInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - return b -} - -// Struct list read XinputInputInfo -func ReadXinputInputInfoList(buf []byte, dest []XinputInputInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputInputInfo{} - b += ReadXinputInputInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputInputInfo -func (v XinputInputInfo) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - return buf -} - -// Write struct list XinputInputInfo -func XinputInputInfoListBytes(buf []byte, list []XinputInputInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKeyInfo' struct definition -// Size: 8 -type XinputKeyInfo struct { - ClassId byte - Len byte - MinKeycode XinputKeyCode - MaxKeycode XinputKeyCode - NumKeys uint16 - // padding: 2 bytes -} - -// Struct read XinputKeyInfo -func ReadXinputKeyInfo(buf []byte, v *XinputKeyInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.MinKeycode = XinputKeyCode(buf[b]) - b += 1 - - v.MaxKeycode = XinputKeyCode(buf[b]) - b += 1 - - v.NumKeys = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return b -} - -// Struct list read XinputKeyInfo -func ReadXinputKeyInfoList(buf []byte, dest []XinputKeyInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKeyInfo{} - b += ReadXinputKeyInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKeyInfo -func (v XinputKeyInfo) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = byte(v.MinKeycode) - b += 1 - - buf[b] = byte(v.MaxKeycode) - b += 1 - - Put16(buf[b:], v.NumKeys) - b += 2 - - b += 2 // padding - - return buf -} - -// Write struct list XinputKeyInfo -func XinputKeyInfoListBytes(buf []byte, list []XinputKeyInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputButtonInfo' struct definition -// Size: 4 -type XinputButtonInfo struct { - ClassId byte - Len byte - NumButtons uint16 -} - -// Struct read XinputButtonInfo -func ReadXinputButtonInfo(buf []byte, v *XinputButtonInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumButtons = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputButtonInfo -func ReadXinputButtonInfoList(buf []byte, dest []XinputButtonInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputButtonInfo{} - b += ReadXinputButtonInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputButtonInfo -func (v XinputButtonInfo) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - Put16(buf[b:], v.NumButtons) - b += 2 - - return buf -} - -// Write struct list XinputButtonInfo -func XinputButtonInfoListBytes(buf []byte, list []XinputButtonInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputAxisInfo' struct definition -// Size: 12 -type XinputAxisInfo struct { - Resolution uint32 - Minimum int32 - Maximum int32 -} - -// Struct read XinputAxisInfo -func ReadXinputAxisInfo(buf []byte, v *XinputAxisInfo) int { - b := 0 - - v.Resolution = Get32(buf[b:]) - b += 4 - - v.Minimum = int32(Get32(buf[b:])) - b += 4 - - v.Maximum = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputAxisInfo -func ReadXinputAxisInfoList(buf []byte, dest []XinputAxisInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputAxisInfo{} - b += ReadXinputAxisInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputAxisInfo -func (v XinputAxisInfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], v.Resolution) - b += 4 - - Put32(buf[b:], uint32(v.Minimum)) - b += 4 - - Put32(buf[b:], uint32(v.Maximum)) - b += 4 - - return buf -} - -// Write struct list XinputAxisInfo -func XinputAxisInfoListBytes(buf []byte, list []XinputAxisInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputValuatorInfo' struct definition -// Size: (8 + pad((int(AxesLen) * 12))) -type XinputValuatorInfo struct { - ClassId byte - Len byte - AxesLen byte - Mode byte - MotionSize uint32 - Axes []XinputAxisInfo // size: pad((int(AxesLen) * 12)) -} - -// Struct read XinputValuatorInfo -func ReadXinputValuatorInfo(buf []byte, v *XinputValuatorInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.AxesLen = buf[b] - b += 1 - - v.Mode = buf[b] - b += 1 - - v.MotionSize = Get32(buf[b:]) - b += 4 - - v.Axes = make([]XinputAxisInfo, v.AxesLen) - b += ReadXinputAxisInfoList(buf[b:], v.Axes) - - return b -} - -// Struct list read XinputValuatorInfo -func ReadXinputValuatorInfoList(buf []byte, dest []XinputValuatorInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputValuatorInfo{} - b += ReadXinputValuatorInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputValuatorInfo -func (v XinputValuatorInfo) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.AxesLen) * 12)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.AxesLen - b += 1 - - buf[b] = v.Mode - b += 1 - - Put32(buf[b:], v.MotionSize) - b += 4 - - b += XinputAxisInfoListBytes(buf[b:], v.Axes) - - return buf -} - -// Write struct list XinputValuatorInfo -func XinputValuatorInfoListBytes(buf []byte, list []XinputValuatorInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputValuatorInfo -func XinputValuatorInfoListSize(list []XinputValuatorInfo) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.AxesLen) * 12))) - } - return size -} - -// 'XinputInputClassInfo' struct definition -// Size: 2 -type XinputInputClassInfo struct { - ClassId byte - EventTypeBase byte -} - -// Struct read XinputInputClassInfo -func ReadXinputInputClassInfo(buf []byte, v *XinputInputClassInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.EventTypeBase = buf[b] - b += 1 - - return b -} - -// Struct list read XinputInputClassInfo -func ReadXinputInputClassInfoList(buf []byte, dest []XinputInputClassInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputInputClassInfo{} - b += ReadXinputInputClassInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputInputClassInfo -func (v XinputInputClassInfo) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.EventTypeBase - b += 1 - - return buf -} - -// Write struct list XinputInputClassInfo -func XinputInputClassInfoListBytes(buf []byte, list []XinputInputClassInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceTimeCoord' struct definition -// Size: 4 -type XinputDeviceTimeCoord struct { - Time Timestamp -} - -// Struct read XinputDeviceTimeCoord -func ReadXinputDeviceTimeCoord(buf []byte, v *XinputDeviceTimeCoord) int { - b := 0 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputDeviceTimeCoord -func ReadXinputDeviceTimeCoordList(buf []byte, dest []XinputDeviceTimeCoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceTimeCoord{} - b += ReadXinputDeviceTimeCoord(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceTimeCoord -func (v XinputDeviceTimeCoord) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - return buf -} - -// Write struct list XinputDeviceTimeCoord -func XinputDeviceTimeCoordListBytes(buf []byte, list []XinputDeviceTimeCoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputFeedbackState' struct definition -// Size: 4 -type XinputFeedbackState struct { - ClassId byte - Id byte - Len uint16 -} - -// Struct read XinputFeedbackState -func ReadXinputFeedbackState(buf []byte, v *XinputFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputFeedbackState -func ReadXinputFeedbackStateList(buf []byte, dest []XinputFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputFeedbackState{} - b += ReadXinputFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputFeedbackState -func (v XinputFeedbackState) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputFeedbackState -func XinputFeedbackStateListBytes(buf []byte, list []XinputFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKbdFeedbackState' struct definition -// Size: 52 -type XinputKbdFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Pitch uint16 - Duration uint16 - LedMask uint32 - LedValues uint32 - GlobalAutoRepeat bool - Click byte - Percent byte - // padding: 1 bytes - AutoRepeats []byte // size: 32 -} - -// Struct read XinputKbdFeedbackState -func ReadXinputKbdFeedbackState(buf []byte, v *XinputKbdFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Pitch = Get16(buf[b:]) - b += 2 - - v.Duration = Get16(buf[b:]) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - if buf[b] == 1 { - v.GlobalAutoRepeat = true - } else { - v.GlobalAutoRepeat = false - } - b += 1 - - v.Click = buf[b] - b += 1 - - v.Percent = buf[b] - b += 1 - - b += 1 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += pad(int(32)) - - return b -} - -// Struct list read XinputKbdFeedbackState -func ReadXinputKbdFeedbackStateList(buf []byte, dest []XinputKbdFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKbdFeedbackState{} - b += ReadXinputKbdFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKbdFeedbackState -func (v XinputKbdFeedbackState) Bytes() []byte { - buf := make([]byte, 52) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put16(buf[b:], v.Pitch) - b += 2 - - Put16(buf[b:], v.Duration) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - if v.GlobalAutoRepeat { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.Click - b += 1 - - buf[b] = v.Percent - b += 1 - - b += 1 // padding - - copy(buf[b:], v.AutoRepeats[:32]) - b += pad(int(32)) - - return buf -} - -// Write struct list XinputKbdFeedbackState -func XinputKbdFeedbackStateListBytes(buf []byte, list []XinputKbdFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputKbdFeedbackState -func XinputKbdFeedbackStateListSize(list []XinputKbdFeedbackState) int { - size := 0 - for _ = range list { - size += 52 - } - return size -} - -// 'XinputPtrFeedbackState' struct definition -// Size: 12 -type XinputPtrFeedbackState struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - AccelNum uint16 - AccelDenom uint16 - Threshold uint16 -} - -// Struct read XinputPtrFeedbackState -func ReadXinputPtrFeedbackState(buf []byte, v *XinputPtrFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.AccelNum = Get16(buf[b:]) - b += 2 - - v.AccelDenom = Get16(buf[b:]) - b += 2 - - v.Threshold = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputPtrFeedbackState -func ReadXinputPtrFeedbackStateList(buf []byte, dest []XinputPtrFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputPtrFeedbackState{} - b += ReadXinputPtrFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputPtrFeedbackState -func (v XinputPtrFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - Put16(buf[b:], v.AccelNum) - b += 2 - - Put16(buf[b:], v.AccelDenom) - b += 2 - - Put16(buf[b:], v.Threshold) - b += 2 - - return buf -} - -// Write struct list XinputPtrFeedbackState -func XinputPtrFeedbackStateListBytes(buf []byte, list []XinputPtrFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputIntegerFeedbackState' struct definition -// Size: 16 -type XinputIntegerFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Resolution uint32 - MinValue int32 - MaxValue int32 -} - -// Struct read XinputIntegerFeedbackState -func ReadXinputIntegerFeedbackState(buf []byte, v *XinputIntegerFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Resolution = Get32(buf[b:]) - b += 4 - - v.MinValue = int32(Get32(buf[b:])) - b += 4 - - v.MaxValue = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputIntegerFeedbackState -func ReadXinputIntegerFeedbackStateList(buf []byte, dest []XinputIntegerFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputIntegerFeedbackState{} - b += ReadXinputIntegerFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputIntegerFeedbackState -func (v XinputIntegerFeedbackState) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.Resolution) - b += 4 - - Put32(buf[b:], uint32(v.MinValue)) - b += 4 - - Put32(buf[b:], uint32(v.MaxValue)) - b += 4 - - return buf -} - -// Write struct list XinputIntegerFeedbackState -func XinputIntegerFeedbackStateListBytes(buf []byte, list []XinputIntegerFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputStringFeedbackState' struct definition -// Size: (8 + pad((int(NumKeysyms) * 4))) -type XinputStringFeedbackState struct { - ClassId byte - Id byte - Len uint16 - MaxSymbols uint16 - NumKeysyms uint16 - Keysyms []Keysym // size: pad((int(NumKeysyms) * 4)) -} - -// Struct read XinputStringFeedbackState -func ReadXinputStringFeedbackState(buf []byte, v *XinputStringFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.MaxSymbols = Get16(buf[b:]) - b += 2 - - v.NumKeysyms = Get16(buf[b:]) - b += 2 - - v.Keysyms = make([]Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputStringFeedbackState -func ReadXinputStringFeedbackStateList(buf []byte, dest []XinputStringFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputStringFeedbackState{} - b += ReadXinputStringFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputStringFeedbackState -func (v XinputStringFeedbackState) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumKeysyms) * 4)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put16(buf[b:], v.MaxSymbols) - b += 2 - - Put16(buf[b:], v.NumKeysyms) - b += 2 - - for i := 0; i < int(v.NumKeysyms); i++ { - Put32(buf[b:], uint32(v.Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputStringFeedbackState -func XinputStringFeedbackStateListBytes(buf []byte, list []XinputStringFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputStringFeedbackState -func XinputStringFeedbackStateListSize(list []XinputStringFeedbackState) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumKeysyms) * 4))) - } - return size -} - -// 'XinputBellFeedbackState' struct definition -// Size: 12 -type XinputBellFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Percent byte - // padding: 3 bytes - Pitch uint16 - Duration uint16 -} - -// Struct read XinputBellFeedbackState -func ReadXinputBellFeedbackState(buf []byte, v *XinputBellFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Percent = buf[b] - b += 1 - - b += 3 // padding - - v.Pitch = Get16(buf[b:]) - b += 2 - - v.Duration = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputBellFeedbackState -func ReadXinputBellFeedbackStateList(buf []byte, dest []XinputBellFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputBellFeedbackState{} - b += ReadXinputBellFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputBellFeedbackState -func (v XinputBellFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Percent - b += 1 - - b += 3 // padding - - Put16(buf[b:], v.Pitch) - b += 2 - - Put16(buf[b:], v.Duration) - b += 2 - - return buf -} - -// Write struct list XinputBellFeedbackState -func XinputBellFeedbackStateListBytes(buf []byte, list []XinputBellFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputLedFeedbackState' struct definition -// Size: 12 -type XinputLedFeedbackState struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 -} - -// Struct read XinputLedFeedbackState -func ReadXinputLedFeedbackState(buf []byte, v *XinputLedFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputLedFeedbackState -func ReadXinputLedFeedbackStateList(buf []byte, dest []XinputLedFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputLedFeedbackState{} - b += ReadXinputLedFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputLedFeedbackState -func (v XinputLedFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - return buf -} - -// Write struct list XinputLedFeedbackState -func XinputLedFeedbackStateListBytes(buf []byte, list []XinputLedFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputFeedbackCtl' struct definition -// Size: 4 -type XinputFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 -} - -// Struct read XinputFeedbackCtl -func ReadXinputFeedbackCtl(buf []byte, v *XinputFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputFeedbackCtl -func ReadXinputFeedbackCtlList(buf []byte, dest []XinputFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputFeedbackCtl{} - b += ReadXinputFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputFeedbackCtl -func (v XinputFeedbackCtl) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputFeedbackCtl -func XinputFeedbackCtlListBytes(buf []byte, list []XinputFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKbdFeedbackCtl' struct definition -// Size: 20 -type XinputKbdFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - Key XinputKeyCode - AutoRepeatMode byte - KeyClickPercent int8 - BellPercent int8 - BellPitch int16 - BellDuration int16 - LedMask uint32 - LedValues uint32 -} - -// Struct read XinputKbdFeedbackCtl -func ReadXinputKbdFeedbackCtl(buf []byte, v *XinputKbdFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Key = XinputKeyCode(buf[b]) - b += 1 - - v.AutoRepeatMode = buf[b] - b += 1 - - v.KeyClickPercent = int8(buf[b]) - b += 1 - - v.BellPercent = int8(buf[b]) - b += 1 - - v.BellPitch = int16(Get16(buf[b:])) - b += 2 - - v.BellDuration = int16(Get16(buf[b:])) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputKbdFeedbackCtl -func ReadXinputKbdFeedbackCtlList(buf []byte, dest []XinputKbdFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKbdFeedbackCtl{} - b += ReadXinputKbdFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKbdFeedbackCtl -func (v XinputKbdFeedbackCtl) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = byte(v.Key) - b += 1 - - buf[b] = v.AutoRepeatMode - b += 1 - - buf[b] = byte(v.KeyClickPercent) - b += 1 - - buf[b] = byte(v.BellPercent) - b += 1 - - Put16(buf[b:], uint16(v.BellPitch)) - b += 2 - - Put16(buf[b:], uint16(v.BellDuration)) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - return buf -} - -// Write struct list XinputKbdFeedbackCtl -func XinputKbdFeedbackCtlListBytes(buf []byte, list []XinputKbdFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputPtrFeedbackCtl' struct definition -// Size: 12 -type XinputPtrFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - Num int16 - Denom int16 - Threshold int16 -} - -// Struct read XinputPtrFeedbackCtl -func ReadXinputPtrFeedbackCtl(buf []byte, v *XinputPtrFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Num = int16(Get16(buf[b:])) - b += 2 - - v.Denom = int16(Get16(buf[b:])) - b += 2 - - v.Threshold = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read XinputPtrFeedbackCtl -func ReadXinputPtrFeedbackCtlList(buf []byte, dest []XinputPtrFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputPtrFeedbackCtl{} - b += ReadXinputPtrFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputPtrFeedbackCtl -func (v XinputPtrFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - Put16(buf[b:], uint16(v.Num)) - b += 2 - - Put16(buf[b:], uint16(v.Denom)) - b += 2 - - Put16(buf[b:], uint16(v.Threshold)) - b += 2 - - return buf -} - -// Write struct list XinputPtrFeedbackCtl -func XinputPtrFeedbackCtlListBytes(buf []byte, list []XinputPtrFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputIntegerFeedbackCtl' struct definition -// Size: 8 -type XinputIntegerFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - IntToDisplay int32 -} - -// Struct read XinputIntegerFeedbackCtl -func ReadXinputIntegerFeedbackCtl(buf []byte, v *XinputIntegerFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.IntToDisplay = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputIntegerFeedbackCtl -func ReadXinputIntegerFeedbackCtlList(buf []byte, dest []XinputIntegerFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputIntegerFeedbackCtl{} - b += ReadXinputIntegerFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputIntegerFeedbackCtl -func (v XinputIntegerFeedbackCtl) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], uint32(v.IntToDisplay)) - b += 4 - - return buf -} - -// Write struct list XinputIntegerFeedbackCtl -func XinputIntegerFeedbackCtlListBytes(buf []byte, list []XinputIntegerFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputStringFeedbackCtl' struct definition -// Size: (8 + pad((int(NumKeysyms) * 4))) -type XinputStringFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - NumKeysyms uint16 - Keysyms []Keysym // size: pad((int(NumKeysyms) * 4)) -} - -// Struct read XinputStringFeedbackCtl -func ReadXinputStringFeedbackCtl(buf []byte, v *XinputStringFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.NumKeysyms = Get16(buf[b:]) - b += 2 - - v.Keysyms = make([]Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputStringFeedbackCtl -func ReadXinputStringFeedbackCtlList(buf []byte, dest []XinputStringFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputStringFeedbackCtl{} - b += ReadXinputStringFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputStringFeedbackCtl -func (v XinputStringFeedbackCtl) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumKeysyms) * 4)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - Put16(buf[b:], v.NumKeysyms) - b += 2 - - for i := 0; i < int(v.NumKeysyms); i++ { - Put32(buf[b:], uint32(v.Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputStringFeedbackCtl -func XinputStringFeedbackCtlListBytes(buf []byte, list []XinputStringFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputStringFeedbackCtl -func XinputStringFeedbackCtlListSize(list []XinputStringFeedbackCtl) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumKeysyms) * 4))) - } - return size -} - -// 'XinputBellFeedbackCtl' struct definition -// Size: 12 -type XinputBellFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - Percent int8 - // padding: 3 bytes - Pitch int16 - Duration int16 -} - -// Struct read XinputBellFeedbackCtl -func ReadXinputBellFeedbackCtl(buf []byte, v *XinputBellFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Percent = int8(buf[b]) - b += 1 - - b += 3 // padding - - v.Pitch = int16(Get16(buf[b:])) - b += 2 - - v.Duration = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read XinputBellFeedbackCtl -func ReadXinputBellFeedbackCtlList(buf []byte, dest []XinputBellFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputBellFeedbackCtl{} - b += ReadXinputBellFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputBellFeedbackCtl -func (v XinputBellFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = byte(v.Percent) - b += 1 - - b += 3 // padding - - Put16(buf[b:], uint16(v.Pitch)) - b += 2 - - Put16(buf[b:], uint16(v.Duration)) - b += 2 - - return buf -} - -// Write struct list XinputBellFeedbackCtl -func XinputBellFeedbackCtlListBytes(buf []byte, list []XinputBellFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputLedFeedbackCtl' struct definition -// Size: 12 -type XinputLedFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 -} - -// Struct read XinputLedFeedbackCtl -func ReadXinputLedFeedbackCtl(buf []byte, v *XinputLedFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputLedFeedbackCtl -func ReadXinputLedFeedbackCtlList(buf []byte, dest []XinputLedFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputLedFeedbackCtl{} - b += ReadXinputLedFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputLedFeedbackCtl -func (v XinputLedFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - return buf -} - -// Write struct list XinputLedFeedbackCtl -func XinputLedFeedbackCtlListBytes(buf []byte, list []XinputLedFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputInputState' struct definition -// Size: 3 -type XinputInputState struct { - ClassId byte - Len byte - NumItems byte -} - -// Struct read XinputInputState -func ReadXinputInputState(buf []byte, v *XinputInputState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumItems = buf[b] - b += 1 - - return b -} - -// Struct list read XinputInputState -func ReadXinputInputStateList(buf []byte, dest []XinputInputState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputInputState{} - b += ReadXinputInputState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputInputState -func (v XinputInputState) Bytes() []byte { - buf := make([]byte, 3) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumItems - b += 1 - - return buf -} - -// Write struct list XinputInputState -func XinputInputStateListBytes(buf []byte, list []XinputInputState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKeyState' struct definition -// Size: 36 -type XinputKeyState struct { - ClassId byte - Len byte - NumKeys byte - // padding: 1 bytes - Keys []byte // size: 32 -} - -// Struct read XinputKeyState -func ReadXinputKeyState(buf []byte, v *XinputKeyState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumKeys = buf[b] - b += 1 - - b += 1 // padding - - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += pad(int(32)) - - return b -} - -// Struct list read XinputKeyState -func ReadXinputKeyStateList(buf []byte, dest []XinputKeyState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKeyState{} - b += ReadXinputKeyState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKeyState -func (v XinputKeyState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumKeys - b += 1 - - b += 1 // padding - - copy(buf[b:], v.Keys[:32]) - b += pad(int(32)) - - return buf -} - -// Write struct list XinputKeyState -func XinputKeyStateListBytes(buf []byte, list []XinputKeyState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputKeyState -func XinputKeyStateListSize(list []XinputKeyState) int { - size := 0 - for _ = range list { - size += 36 - } - return size -} - -// 'XinputButtonState' struct definition -// Size: 36 -type XinputButtonState struct { - ClassId byte - Len byte - NumButtons byte - // padding: 1 bytes - Buttons []byte // size: 32 -} - -// Struct read XinputButtonState -func ReadXinputButtonState(buf []byte, v *XinputButtonState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumButtons = buf[b] - b += 1 - - b += 1 // padding - - v.Buttons = make([]byte, 32) - copy(v.Buttons[:32], buf[b:]) - b += pad(int(32)) - - return b -} - -// Struct list read XinputButtonState -func ReadXinputButtonStateList(buf []byte, dest []XinputButtonState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputButtonState{} - b += ReadXinputButtonState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputButtonState -func (v XinputButtonState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumButtons - b += 1 - - b += 1 // padding - - copy(buf[b:], v.Buttons[:32]) - b += pad(int(32)) - - return buf -} - -// Write struct list XinputButtonState -func XinputButtonStateListBytes(buf []byte, list []XinputButtonState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputButtonState -func XinputButtonStateListSize(list []XinputButtonState) int { - size := 0 - for _ = range list { - size += 36 - } - return size -} - -// 'XinputValuatorState' struct definition -// Size: (4 + pad((int(NumValuators) * 4))) -type XinputValuatorState struct { - ClassId byte - Len byte - NumValuators byte - Mode byte - Valuators []uint32 // size: pad((int(NumValuators) * 4)) -} - -// Struct read XinputValuatorState -func ReadXinputValuatorState(buf []byte, v *XinputValuatorState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumValuators = buf[b] - b += 1 - - v.Mode = buf[b] - b += 1 - - v.Valuators = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.Valuators[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputValuatorState -func ReadXinputValuatorStateList(buf []byte, dest []XinputValuatorState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputValuatorState{} - b += ReadXinputValuatorState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputValuatorState -func (v XinputValuatorState) Bytes() []byte { - buf := make([]byte, (4 + pad((int(v.NumValuators) * 4)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.Mode - b += 1 - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputValuatorState -func XinputValuatorStateListBytes(buf []byte, list []XinputValuatorState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputValuatorState -func XinputValuatorStateListSize(list []XinputValuatorState) int { - size := 0 - for _, item := range list { - size += (4 + pad((int(item.NumValuators) * 4))) - } - return size -} - -// 'XinputDeviceState' struct definition -// Size: 4 -type XinputDeviceState struct { - ControlId uint16 - Len uint16 -} - -// Struct read XinputDeviceState -func ReadXinputDeviceState(buf []byte, v *XinputDeviceState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputDeviceState -func ReadXinputDeviceStateList(buf []byte, dest []XinputDeviceState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceState{} - b += ReadXinputDeviceState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceState -func (v XinputDeviceState) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputDeviceState -func XinputDeviceStateListBytes(buf []byte, list []XinputDeviceState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceResolutionState' struct definition -// Size: (((8 + pad((int(NumValuators) * 4))) + pad((int(NumValuators) * 4))) + pad((int(NumValuators) * 4))) -type XinputDeviceResolutionState struct { - ControlId uint16 - Len uint16 - NumValuators uint32 - ResolutionValues []uint32 // size: pad((int(NumValuators) * 4)) - ResolutionMin []uint32 // size: pad((int(NumValuators) * 4)) - ResolutionMax []uint32 // size: pad((int(NumValuators) * 4)) -} - -// Struct read XinputDeviceResolutionState -func ReadXinputDeviceResolutionState(buf []byte, v *XinputDeviceResolutionState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.NumValuators = Get32(buf[b:]) - b += 4 - - v.ResolutionValues = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionValues[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.ResolutionMin = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionMin[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.ResolutionMax = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionMax[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputDeviceResolutionState -func ReadXinputDeviceResolutionStateList(buf []byte, dest []XinputDeviceResolutionState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceResolutionState{} - b += ReadXinputDeviceResolutionState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceResolutionState -func (v XinputDeviceResolutionState) Bytes() []byte { - buf := make([]byte, (((8 + pad((int(v.NumValuators) * 4))) + pad((int(v.NumValuators) * 4))) + pad((int(v.NumValuators) * 4)))) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.NumValuators) - b += 4 - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionValues[i]) - b += 4 - } - b = pad(b) - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionMin[i]) - b += 4 - } - b = pad(b) - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionMax[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputDeviceResolutionState -func XinputDeviceResolutionStateListBytes(buf []byte, list []XinputDeviceResolutionState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputDeviceResolutionState -func XinputDeviceResolutionStateListSize(list []XinputDeviceResolutionState) int { - size := 0 - for _, item := range list { - size += (((8 + pad((int(item.NumValuators) * 4))) + pad((int(item.NumValuators) * 4))) + pad((int(item.NumValuators) * 4))) - } - return size -} - -// 'XinputDeviceAbsCalibState' struct definition -// Size: 36 -type XinputDeviceAbsCalibState struct { - ControlId uint16 - Len uint16 - MinX int32 - MaxX int32 - MinY int32 - MaxY int32 - FlipX uint32 - FlipY uint32 - Rotation uint32 - ButtonThreshold uint32 -} - -// Struct read XinputDeviceAbsCalibState -func ReadXinputDeviceAbsCalibState(buf []byte, v *XinputDeviceAbsCalibState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.MinX = int32(Get32(buf[b:])) - b += 4 - - v.MaxX = int32(Get32(buf[b:])) - b += 4 - - v.MinY = int32(Get32(buf[b:])) - b += 4 - - v.MaxY = int32(Get32(buf[b:])) - b += 4 - - v.FlipX = Get32(buf[b:]) - b += 4 - - v.FlipY = Get32(buf[b:]) - b += 4 - - v.Rotation = Get32(buf[b:]) - b += 4 - - v.ButtonThreshold = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsCalibState -func ReadXinputDeviceAbsCalibStateList(buf []byte, dest []XinputDeviceAbsCalibState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsCalibState{} - b += ReadXinputDeviceAbsCalibState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsCalibState -func (v XinputDeviceAbsCalibState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], uint32(v.MinX)) - b += 4 - - Put32(buf[b:], uint32(v.MaxX)) - b += 4 - - Put32(buf[b:], uint32(v.MinY)) - b += 4 - - Put32(buf[b:], uint32(v.MaxY)) - b += 4 - - Put32(buf[b:], v.FlipX) - b += 4 - - Put32(buf[b:], v.FlipY) - b += 4 - - Put32(buf[b:], v.Rotation) - b += 4 - - Put32(buf[b:], v.ButtonThreshold) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsCalibState -func XinputDeviceAbsCalibStateListBytes(buf []byte, list []XinputDeviceAbsCalibState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceAbsAreaState' struct definition -// Size: 28 -type XinputDeviceAbsAreaState struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width uint32 - Height uint32 - Screen uint32 - Following uint32 -} - -// Struct read XinputDeviceAbsAreaState -func ReadXinputDeviceAbsAreaState(buf []byte, v *XinputDeviceAbsAreaState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.OffsetX = Get32(buf[b:]) - b += 4 - - v.OffsetY = Get32(buf[b:]) - b += 4 - - v.Width = Get32(buf[b:]) - b += 4 - - v.Height = Get32(buf[b:]) - b += 4 - - v.Screen = Get32(buf[b:]) - b += 4 - - v.Following = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsAreaState -func ReadXinputDeviceAbsAreaStateList(buf []byte, dest []XinputDeviceAbsAreaState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsAreaState{} - b += ReadXinputDeviceAbsAreaState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsAreaState -func (v XinputDeviceAbsAreaState) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.OffsetX) - b += 4 - - Put32(buf[b:], v.OffsetY) - b += 4 - - Put32(buf[b:], v.Width) - b += 4 - - Put32(buf[b:], v.Height) - b += 4 - - Put32(buf[b:], v.Screen) - b += 4 - - Put32(buf[b:], v.Following) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsAreaState -func XinputDeviceAbsAreaStateListBytes(buf []byte, list []XinputDeviceAbsAreaState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceCoreState' struct definition -// Size: 8 -type XinputDeviceCoreState struct { - ControlId uint16 - Len uint16 - Status byte - Iscore byte - // padding: 2 bytes -} - -// Struct read XinputDeviceCoreState -func ReadXinputDeviceCoreState(buf []byte, v *XinputDeviceCoreState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Status = buf[b] - b += 1 - - v.Iscore = buf[b] - b += 1 - - b += 2 // padding - - return b -} - -// Struct list read XinputDeviceCoreState -func ReadXinputDeviceCoreStateList(buf []byte, dest []XinputDeviceCoreState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceCoreState{} - b += ReadXinputDeviceCoreState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceCoreState -func (v XinputDeviceCoreState) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Status - b += 1 - - buf[b] = v.Iscore - b += 1 - - b += 2 // padding - - return buf -} - -// Write struct list XinputDeviceCoreState -func XinputDeviceCoreStateListBytes(buf []byte, list []XinputDeviceCoreState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceEnableState' struct definition -// Size: 8 -type XinputDeviceEnableState struct { - ControlId uint16 - Len uint16 - Enable byte - // padding: 3 bytes -} - -// Struct read XinputDeviceEnableState -func ReadXinputDeviceEnableState(buf []byte, v *XinputDeviceEnableState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Enable = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XinputDeviceEnableState -func ReadXinputDeviceEnableStateList(buf []byte, dest []XinputDeviceEnableState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceEnableState{} - b += ReadXinputDeviceEnableState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceEnableState -func (v XinputDeviceEnableState) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Enable - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XinputDeviceEnableState -func XinputDeviceEnableStateListBytes(buf []byte, list []XinputDeviceEnableState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceCtl' struct definition -// Size: 4 -type XinputDeviceCtl struct { - ControlId uint16 - Len uint16 -} - -// Struct read XinputDeviceCtl -func ReadXinputDeviceCtl(buf []byte, v *XinputDeviceCtl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputDeviceCtl -func ReadXinputDeviceCtlList(buf []byte, dest []XinputDeviceCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceCtl{} - b += ReadXinputDeviceCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceCtl -func (v XinputDeviceCtl) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputDeviceCtl -func XinputDeviceCtlListBytes(buf []byte, list []XinputDeviceCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceResolutionCtl' struct definition -// Size: (6 + pad((int(NumValuators) * 4))) -type XinputDeviceResolutionCtl struct { - ControlId uint16 - Len uint16 - FirstValuator byte - NumValuators byte - ResolutionValues []uint32 // size: pad((int(NumValuators) * 4)) -} - -// Struct read XinputDeviceResolutionCtl -func ReadXinputDeviceResolutionCtl(buf []byte, v *XinputDeviceResolutionCtl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.FirstValuator = buf[b] - b += 1 - - v.NumValuators = buf[b] - b += 1 - - v.ResolutionValues = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionValues[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputDeviceResolutionCtl -func ReadXinputDeviceResolutionCtlList(buf []byte, dest []XinputDeviceResolutionCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceResolutionCtl{} - b += ReadXinputDeviceResolutionCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceResolutionCtl -func (v XinputDeviceResolutionCtl) Bytes() []byte { - buf := make([]byte, (6 + pad((int(v.NumValuators) * 4)))) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.FirstValuator - b += 1 - - buf[b] = v.NumValuators - b += 1 - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionValues[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputDeviceResolutionCtl -func XinputDeviceResolutionCtlListBytes(buf []byte, list []XinputDeviceResolutionCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputDeviceResolutionCtl -func XinputDeviceResolutionCtlListSize(list []XinputDeviceResolutionCtl) int { - size := 0 - for _, item := range list { - size += (6 + pad((int(item.NumValuators) * 4))) - } - return size -} - -// 'XinputDeviceAbsCalibCtl' struct definition -// Size: 36 -type XinputDeviceAbsCalibCtl struct { - ControlId uint16 - Len uint16 - MinX int32 - MaxX int32 - MinY int32 - MaxY int32 - FlipX uint32 - FlipY uint32 - Rotation uint32 - ButtonThreshold uint32 -} - -// Struct read XinputDeviceAbsCalibCtl -func ReadXinputDeviceAbsCalibCtl(buf []byte, v *XinputDeviceAbsCalibCtl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.MinX = int32(Get32(buf[b:])) - b += 4 - - v.MaxX = int32(Get32(buf[b:])) - b += 4 - - v.MinY = int32(Get32(buf[b:])) - b += 4 - - v.MaxY = int32(Get32(buf[b:])) - b += 4 - - v.FlipX = Get32(buf[b:]) - b += 4 - - v.FlipY = Get32(buf[b:]) - b += 4 - - v.Rotation = Get32(buf[b:]) - b += 4 - - v.ButtonThreshold = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsCalibCtl -func ReadXinputDeviceAbsCalibCtlList(buf []byte, dest []XinputDeviceAbsCalibCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsCalibCtl{} - b += ReadXinputDeviceAbsCalibCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsCalibCtl -func (v XinputDeviceAbsCalibCtl) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], uint32(v.MinX)) - b += 4 - - Put32(buf[b:], uint32(v.MaxX)) - b += 4 - - Put32(buf[b:], uint32(v.MinY)) - b += 4 - - Put32(buf[b:], uint32(v.MaxY)) - b += 4 - - Put32(buf[b:], v.FlipX) - b += 4 - - Put32(buf[b:], v.FlipY) - b += 4 - - Put32(buf[b:], v.Rotation) - b += 4 - - Put32(buf[b:], v.ButtonThreshold) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsCalibCtl -func XinputDeviceAbsCalibCtlListBytes(buf []byte, list []XinputDeviceAbsCalibCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceAbsAreaCtrl' struct definition -// Size: 28 -type XinputDeviceAbsAreaCtrl struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width int32 - Height int32 - Screen int32 - Following uint32 -} - -// Struct read XinputDeviceAbsAreaCtrl -func ReadXinputDeviceAbsAreaCtrl(buf []byte, v *XinputDeviceAbsAreaCtrl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.OffsetX = Get32(buf[b:]) - b += 4 - - v.OffsetY = Get32(buf[b:]) - b += 4 - - v.Width = int32(Get32(buf[b:])) - b += 4 - - v.Height = int32(Get32(buf[b:])) - b += 4 - - v.Screen = int32(Get32(buf[b:])) - b += 4 - - v.Following = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsAreaCtrl -func ReadXinputDeviceAbsAreaCtrlList(buf []byte, dest []XinputDeviceAbsAreaCtrl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsAreaCtrl{} - b += ReadXinputDeviceAbsAreaCtrl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsAreaCtrl -func (v XinputDeviceAbsAreaCtrl) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.OffsetX) - b += 4 - - Put32(buf[b:], v.OffsetY) - b += 4 - - Put32(buf[b:], uint32(v.Width)) - b += 4 - - Put32(buf[b:], uint32(v.Height)) - b += 4 - - Put32(buf[b:], uint32(v.Screen)) - b += 4 - - Put32(buf[b:], v.Following) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsAreaCtrl -func XinputDeviceAbsAreaCtrlListBytes(buf []byte, list []XinputDeviceAbsAreaCtrl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceCoreCtrl' struct definition -// Size: 8 -type XinputDeviceCoreCtrl struct { - ControlId uint16 - Len uint16 - Status byte - // padding: 3 bytes -} - -// Struct read XinputDeviceCoreCtrl -func ReadXinputDeviceCoreCtrl(buf []byte, v *XinputDeviceCoreCtrl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Status = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XinputDeviceCoreCtrl -func ReadXinputDeviceCoreCtrlList(buf []byte, dest []XinputDeviceCoreCtrl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceCoreCtrl{} - b += ReadXinputDeviceCoreCtrl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceCoreCtrl -func (v XinputDeviceCoreCtrl) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Status - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XinputDeviceCoreCtrl -func XinputDeviceCoreCtrlListBytes(buf []byte, list []XinputDeviceCoreCtrl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceEnableCtrl' struct definition -// Size: 8 -type XinputDeviceEnableCtrl struct { - ControlId uint16 - Len uint16 - Enable byte - // padding: 3 bytes -} - -// Struct read XinputDeviceEnableCtrl -func ReadXinputDeviceEnableCtrl(buf []byte, v *XinputDeviceEnableCtrl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Enable = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XinputDeviceEnableCtrl -func ReadXinputDeviceEnableCtrlList(buf []byte, dest []XinputDeviceEnableCtrl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceEnableCtrl{} - b += ReadXinputDeviceEnableCtrl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceEnableCtrl -func (v XinputDeviceEnableCtrl) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Enable - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XinputDeviceEnableCtrl -func XinputDeviceEnableCtrlListBytes(buf []byte, list []XinputDeviceEnableCtrl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Event definition XinputDeviceValuator (0) -// Size: 32 - -const XinputDeviceValuator = 0 - -type XinputDeviceValuatorEvent struct { - Sequence uint16 - DeviceId byte - DeviceState uint16 - NumValuators byte - FirstValuator byte - Valuators []int32 // size: 24 -} - -// Event read XinputDeviceValuator -func NewXinputDeviceValuatorEvent(buf []byte) Event { - v := XinputDeviceValuatorEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.DeviceState = Get16(buf[b:]) - b += 2 - - v.NumValuators = buf[b] - b += 1 - - v.FirstValuator = buf[b] - b += 1 - - v.Valuators = make([]int32, 6) - for i := 0; i < int(6); i++ { - v.Valuators[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -// Event write XinputDeviceValuator -func (v XinputDeviceValuatorEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - Put16(buf[b:], v.DeviceState) - b += 2 - - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.FirstValuator - b += 1 - - for i := 0; i < int(6); i++ { - Put32(buf[b:], uint32(v.Valuators[i])) - b += 4 - } - b = pad(b) - - return buf -} - -func (v XinputDeviceValuatorEvent) ImplementsEvent() {} - -func (v XinputDeviceValuatorEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceValuatorEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("DeviceState: %d", v.DeviceState)) - fieldVals = append(fieldVals, sprintf("NumValuators: %d", v.NumValuators)) - fieldVals = append(fieldVals, sprintf("FirstValuator: %d", v.FirstValuator)) - return "XinputDeviceValuator {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][0] = NewXinputDeviceValuatorEvent -} - -// Event definition XinputDeviceKeyPress (1) -// Size: 32 - -const XinputDeviceKeyPress = 1 - -type XinputDeviceKeyPressEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - DeviceId byte -} - -// Event read XinputDeviceKeyPress -func NewXinputDeviceKeyPressEvent(buf []byte) Event { - v := XinputDeviceKeyPressEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.DeviceId = buf[b] - b += 1 - - return v -} - -// Event write XinputDeviceKeyPress -func (v XinputDeviceKeyPressEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.DeviceId - b += 1 - - return buf -} - -func (v XinputDeviceKeyPressEvent) ImplementsEvent() {} - -func (v XinputDeviceKeyPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceKeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceKeyPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][1] = NewXinputDeviceKeyPressEvent -} - -// Event definition XinputFocusIn (6) -// Size: 32 - -const XinputFocusIn = 6 - -type XinputFocusInEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Window Window - Mode byte - DeviceId byte - // padding: 18 bytes -} - -// Event read XinputFocusIn -func NewXinputFocusInEvent(buf []byte) Event { - v := XinputFocusInEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Mode = buf[b] - b += 1 - - v.DeviceId = buf[b] - b += 1 - - b += 18 // padding - - return v -} - -// Event write XinputFocusIn -func (v XinputFocusInEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 6 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - buf[b] = v.Mode - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 18 // padding - - return buf -} - -func (v XinputFocusInEvent) ImplementsEvent() {} - -func (v XinputFocusInEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputFocusInEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputFocusIn {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][6] = NewXinputFocusInEvent -} - -// Event definition XinputDeviceStateNotify (10) -// Size: 32 - -const XinputDeviceStateNotify = 10 - -type XinputDeviceStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Time Timestamp - NumKeys byte - NumButtons byte - NumValuators byte - ClassesReported byte - Buttons []byte // size: 4 - Keys []byte // size: 4 - Valuators []uint32 // size: 12 -} - -// Event read XinputDeviceStateNotify -func NewXinputDeviceStateNotifyEvent(buf []byte) Event { - v := XinputDeviceStateNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.NumKeys = buf[b] - b += 1 - - v.NumButtons = buf[b] - b += 1 - - v.NumValuators = buf[b] - b += 1 - - v.ClassesReported = buf[b] - b += 1 - - v.Buttons = make([]byte, 4) - copy(v.Buttons[:4], buf[b:]) - b += pad(int(4)) - - v.Keys = make([]byte, 4) - copy(v.Keys[:4], buf[b:]) - b += pad(int(4)) - - v.Valuators = make([]uint32, 3) - for i := 0; i < int(3); i++ { - v.Valuators[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Event write XinputDeviceStateNotify -func (v XinputDeviceStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 10 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.NumKeys - b += 1 - - buf[b] = v.NumButtons - b += 1 - - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.ClassesReported - b += 1 - - copy(buf[b:], v.Buttons[:4]) - b += pad(int(4)) - - copy(buf[b:], v.Keys[:4]) - b += pad(int(4)) - - for i := 0; i < int(3); i++ { - Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = pad(b) - - return buf -} - -func (v XinputDeviceStateNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 9) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("NumKeys: %d", v.NumKeys)) - fieldVals = append(fieldVals, sprintf("NumButtons: %d", v.NumButtons)) - fieldVals = append(fieldVals, sprintf("NumValuators: %d", v.NumValuators)) - fieldVals = append(fieldVals, sprintf("ClassesReported: %d", v.ClassesReported)) - return "XinputDeviceStateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][10] = NewXinputDeviceStateNotifyEvent -} - -// Event definition XinputDeviceMappingNotify (11) -// Size: 32 - -const XinputDeviceMappingNotify = 11 - -type XinputDeviceMappingNotifyEvent struct { - Sequence uint16 - DeviceId byte - Request byte - FirstKeycode XinputKeyCode - Count byte - // padding: 1 bytes - Time Timestamp - // padding: 20 bytes -} - -// Event read XinputDeviceMappingNotify -func NewXinputDeviceMappingNotifyEvent(buf []byte) Event { - v := XinputDeviceMappingNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Request = buf[b] - b += 1 - - v.FirstKeycode = XinputKeyCode(buf[b]) - b += 1 - - v.Count = buf[b] - b += 1 - - b += 1 // padding - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -// Event write XinputDeviceMappingNotify -func (v XinputDeviceMappingNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 11 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 - - buf[b] = v.Count - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - b += 20 // padding - - return buf -} - -func (v XinputDeviceMappingNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceMappingNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceMappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - return "XinputDeviceMappingNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][11] = NewXinputDeviceMappingNotifyEvent -} - -// Event definition XinputChangeDeviceNotify (12) -// Size: 32 - -const XinputChangeDeviceNotify = 12 - -type XinputChangeDeviceNotifyEvent struct { - Sequence uint16 - DeviceId byte - Time Timestamp - Request byte - // padding: 23 bytes -} - -// Event read XinputChangeDeviceNotify -func NewXinputChangeDeviceNotifyEvent(buf []byte) Event { - v := XinputChangeDeviceNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Request = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -// Event write XinputChangeDeviceNotify -func (v XinputChangeDeviceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 12 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.Request - b += 1 - - b += 23 // padding - - return buf -} - -func (v XinputChangeDeviceNotifyEvent) ImplementsEvent() {} - -func (v XinputChangeDeviceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputChangeDeviceNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Request: %d", v.Request)) - return "XinputChangeDeviceNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][12] = NewXinputChangeDeviceNotifyEvent -} - -// Event definition XinputDeviceKeyStateNotify (13) -// Size: 32 - -const XinputDeviceKeyStateNotify = 13 - -type XinputDeviceKeyStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Keys []byte // size: 28 -} - -// Event read XinputDeviceKeyStateNotify -func NewXinputDeviceKeyStateNotifyEvent(buf []byte) Event { - v := XinputDeviceKeyStateNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Keys = make([]byte, 28) - copy(v.Keys[:28], buf[b:]) - b += pad(int(28)) - - return v -} - -// Event write XinputDeviceKeyStateNotify -func (v XinputDeviceKeyStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - copy(buf[b:], v.Keys[:28]) - b += pad(int(28)) - - return buf -} - -func (v XinputDeviceKeyStateNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceKeyStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceKeyStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceKeyStateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][13] = NewXinputDeviceKeyStateNotifyEvent -} - -// Event definition XinputDeviceButtonStateNotify (14) -// Size: 32 - -const XinputDeviceButtonStateNotify = 14 - -type XinputDeviceButtonStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Buttons []byte // size: 28 -} - -// Event read XinputDeviceButtonStateNotify -func NewXinputDeviceButtonStateNotifyEvent(buf []byte) Event { - v := XinputDeviceButtonStateNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Buttons = make([]byte, 28) - copy(v.Buttons[:28], buf[b:]) - b += pad(int(28)) - - return v -} - -// Event write XinputDeviceButtonStateNotify -func (v XinputDeviceButtonStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - copy(buf[b:], v.Buttons[:28]) - b += pad(int(28)) - - return buf -} - -func (v XinputDeviceButtonStateNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceButtonStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceButtonStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceButtonStateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][14] = NewXinputDeviceButtonStateNotifyEvent -} - -// Event definition XinputDevicePresenceNotify (15) -// Size: 32 - -const XinputDevicePresenceNotify = 15 - -type XinputDevicePresenceNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Devchange byte - DeviceId byte - Control uint16 - // padding: 20 bytes -} - -// Event read XinputDevicePresenceNotify -func NewXinputDevicePresenceNotifyEvent(buf []byte) Event { - v := XinputDevicePresenceNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Devchange = buf[b] - b += 1 - - v.DeviceId = buf[b] - b += 1 - - v.Control = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - return v -} - -// Event write XinputDevicePresenceNotify -func (v XinputDevicePresenceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 15 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.Devchange - b += 1 - - buf[b] = v.DeviceId - b += 1 - - Put16(buf[b:], v.Control) - b += 2 - - b += 20 // padding - - return buf -} - -func (v XinputDevicePresenceNotifyEvent) ImplementsEvent() {} - -func (v XinputDevicePresenceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDevicePresenceNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Devchange: %d", v.Devchange)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Control: %d", v.Control)) - return "XinputDevicePresenceNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][15] = NewXinputDevicePresenceNotifyEvent -} - -// EventCopy definition XinputDeviceKeyRelease (2) - -const XinputDeviceKeyRelease = 2 - -type XinputDeviceKeyReleaseEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceKeyReleaseEvent(buf []byte) Event { - return XinputDeviceKeyReleaseEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceKeyReleaseEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceKeyReleaseEvent) ImplementsEvent() {} - -func (v XinputDeviceKeyReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceKeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceKeyRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][2] = NewXinputDeviceKeyReleaseEvent -} - -// EventCopy definition XinputDeviceButtonPress (3) - -const XinputDeviceButtonPress = 3 - -type XinputDeviceButtonPressEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceButtonPressEvent(buf []byte) Event { - return XinputDeviceButtonPressEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceButtonPressEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceButtonPressEvent) ImplementsEvent() {} - -func (v XinputDeviceButtonPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceButtonPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][3] = NewXinputDeviceButtonPressEvent -} - -// EventCopy definition XinputDeviceButtonRelease (4) - -const XinputDeviceButtonRelease = 4 - -type XinputDeviceButtonReleaseEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceButtonReleaseEvent(buf []byte) Event { - return XinputDeviceButtonReleaseEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceButtonReleaseEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceButtonReleaseEvent) ImplementsEvent() {} - -func (v XinputDeviceButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceButtonRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][4] = NewXinputDeviceButtonReleaseEvent -} - -// EventCopy definition XinputDeviceMotionNotify (5) - -const XinputDeviceMotionNotify = 5 - -type XinputDeviceMotionNotifyEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceMotionNotifyEvent(buf []byte) Event { - return XinputDeviceMotionNotifyEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceMotionNotifyEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceMotionNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceMotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceMotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceMotionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][5] = NewXinputDeviceMotionNotifyEvent -} - -// EventCopy definition XinputProximityIn (8) - -const XinputProximityIn = 8 - -type XinputProximityInEvent XinputDeviceKeyPressEvent - -func NewXinputProximityInEvent(buf []byte) Event { - return XinputProximityInEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputProximityInEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputProximityInEvent) ImplementsEvent() {} - -func (v XinputProximityInEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputProximityInEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputProximityIn {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][8] = NewXinputProximityInEvent -} - -// EventCopy definition XinputProximityOut (9) - -const XinputProximityOut = 9 - -type XinputProximityOutEvent XinputDeviceKeyPressEvent - -func NewXinputProximityOutEvent(buf []byte) Event { - return XinputProximityOutEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputProximityOutEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputProximityOutEvent) ImplementsEvent() {} - -func (v XinputProximityOutEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputProximityOutEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputProximityOut {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][9] = NewXinputProximityOutEvent -} - -// EventCopy definition XinputFocusOut (7) - -const XinputFocusOut = 7 - -type XinputFocusOutEvent XinputFocusInEvent - -func NewXinputFocusOutEvent(buf []byte) Event { - return XinputFocusOutEvent(NewXinputFocusInEvent(buf).(XinputFocusInEvent)) -} - -func (v XinputFocusOutEvent) Bytes() []byte { - return XinputFocusInEvent(v).Bytes() -} - -func (v XinputFocusOutEvent) ImplementsEvent() {} - -func (v XinputFocusOutEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputFocusOutEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputFocusOut {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][7] = NewXinputFocusOutEvent -} - -// Error definition XinputDevice (0) -// Size: 32 - -const BadXinputDevice = 0 - -type XinputDeviceError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputDevice -func NewXinputDeviceError(buf []byte) Error { - v := XinputDeviceError{} - v.NiceName = "XinputDevice" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputDeviceError) ImplementsError() {} - -func (err XinputDeviceError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputDeviceError) BadId() uint32 { - return 0 -} - -func (err XinputDeviceError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputDevice {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][0] = NewXinputDeviceError -} - -// Error definition XinputEvent (1) -// Size: 32 - -const BadXinputEvent = 1 - -type XinputEventError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputEvent -func NewXinputEventError(buf []byte) Error { - v := XinputEventError{} - v.NiceName = "XinputEvent" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputEventError) ImplementsError() {} - -func (err XinputEventError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputEventError) BadId() uint32 { - return 0 -} - -func (err XinputEventError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputEvent {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][1] = NewXinputEventError -} - -// Error definition XinputMode (2) -// Size: 32 - -const BadXinputMode = 2 - -type XinputModeError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputMode -func NewXinputModeError(buf []byte) Error { - v := XinputModeError{} - v.NiceName = "XinputMode" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputModeError) ImplementsError() {} - -func (err XinputModeError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputModeError) BadId() uint32 { - return 0 -} - -func (err XinputModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputMode {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][2] = NewXinputModeError -} - -// Error definition XinputDeviceBusy (3) -// Size: 32 - -const BadXinputDeviceBusy = 3 - -type XinputDeviceBusyError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputDeviceBusy -func NewXinputDeviceBusyError(buf []byte) Error { - v := XinputDeviceBusyError{} - v.NiceName = "XinputDeviceBusy" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputDeviceBusyError) ImplementsError() {} - -func (err XinputDeviceBusyError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputDeviceBusyError) BadId() uint32 { - return 0 -} - -func (err XinputDeviceBusyError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputDeviceBusy {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][3] = NewXinputDeviceBusyError -} - -// Error definition XinputClass (4) -// Size: 32 - -const BadXinputClass = 4 - -type XinputClassError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputClass -func NewXinputClassError(buf []byte) Error { - v := XinputClassError{} - v.NiceName = "XinputClass" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputClassError) ImplementsError() {} - -func (err XinputClassError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputClassError) BadId() uint32 { - return 0 -} - -func (err XinputClassError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputClass {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][4] = NewXinputClassError -} - -// Request XinputGetExtensionVersion -// size: pad((8 + pad((int(NameLen) * 1)))) -type XinputGetExtensionVersionCookie struct { - *cookie -} - -func (c *Conn) XinputGetExtensionVersion(NameLen uint16, Name string) XinputGetExtensionVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetExtensionVersionRequest(NameLen, Name), cookie) - return XinputGetExtensionVersionCookie{cookie} -} - -func (c *Conn) XinputGetExtensionVersionUnchecked(NameLen uint16, Name string) XinputGetExtensionVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetExtensionVersionRequest(NameLen, Name), cookie) - return XinputGetExtensionVersionCookie{cookie} -} - -// Request reply for XinputGetExtensionVersion -// size: 32 -type XinputGetExtensionVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 - Present bool - // padding: 19 bytes -} - -// Waits and reads reply data from request XinputGetExtensionVersion -func (cook XinputGetExtensionVersionCookie) Reply() (*XinputGetExtensionVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetExtensionVersionReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetExtensionVersion -func xinputGetExtensionVersionReply(buf []byte) *XinputGetExtensionVersionReply { - v := new(XinputGetExtensionVersionReply) - 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 - - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false - } - b += 1 - - b += 19 // padding - - return v -} - -func (cook XinputGetExtensionVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetExtensionVersion -func (c *Conn) xinputGetExtensionVersionRequest(NameLen uint16, Name string) []byte { - size := pad((8 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request XinputListInputDevices -// size: 4 -type XinputListInputDevicesCookie struct { - *cookie -} - -func (c *Conn) XinputListInputDevices() XinputListInputDevicesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputListInputDevicesRequest(), cookie) - return XinputListInputDevicesCookie{cookie} -} - -func (c *Conn) XinputListInputDevicesUnchecked() XinputListInputDevicesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputListInputDevicesRequest(), cookie) - return XinputListInputDevicesCookie{cookie} -} - -// Request reply for XinputListInputDevices -// size: (32 + pad((int(DevicesLen) * 8))) -type XinputListInputDevicesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DevicesLen byte - // padding: 23 bytes - Devices []XinputDeviceInfo // size: pad((int(DevicesLen) * 8)) -} - -// Waits and reads reply data from request XinputListInputDevices -func (cook XinputListInputDevicesCookie) Reply() (*XinputListInputDevicesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputListInputDevicesReply(buf), nil -} - -// Read reply into structure from buffer for XinputListInputDevices -func xinputListInputDevicesReply(buf []byte) *XinputListInputDevicesReply { - v := new(XinputListInputDevicesReply) - 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.DevicesLen = buf[b] - b += 1 - - b += 23 // padding - - v.Devices = make([]XinputDeviceInfo, v.DevicesLen) - b += ReadXinputDeviceInfoList(buf[b:], v.Devices) - - return v -} - -func (cook XinputListInputDevicesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputListInputDevices -func (c *Conn) xinputListInputDevicesRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - 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 XinputOpenDevice -// size: 8 -type XinputOpenDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputOpenDevice(DeviceId byte) XinputOpenDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputOpenDeviceRequest(DeviceId), cookie) - return XinputOpenDeviceCookie{cookie} -} - -func (c *Conn) XinputOpenDeviceUnchecked(DeviceId byte) XinputOpenDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputOpenDeviceRequest(DeviceId), cookie) - return XinputOpenDeviceCookie{cookie} -} - -// Request reply for XinputOpenDevice -// size: (32 + pad((int(NumClasses) * 2))) -type XinputOpenDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClasses byte - // padding: 23 bytes - ClassInfo []XinputInputClassInfo // size: pad((int(NumClasses) * 2)) -} - -// Waits and reads reply data from request XinputOpenDevice -func (cook XinputOpenDeviceCookie) Reply() (*XinputOpenDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputOpenDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputOpenDevice -func xinputOpenDeviceReply(buf []byte) *XinputOpenDeviceReply { - v := new(XinputOpenDeviceReply) - 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.NumClasses = buf[b] - b += 1 - - b += 23 // padding - - v.ClassInfo = make([]XinputInputClassInfo, v.NumClasses) - b += ReadXinputInputClassInfoList(buf[b:], v.ClassInfo) - - return v -} - -func (cook XinputOpenDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputOpenDevice -func (c *Conn) xinputOpenDeviceRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - 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] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputCloseDevice -// size: 8 -type XinputCloseDeviceCookie struct { - *cookie -} - -// Write request to wire for XinputCloseDevice -func (c *Conn) XinputCloseDevice(DeviceId byte) XinputCloseDeviceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputCloseDeviceRequest(DeviceId), cookie) - return XinputCloseDeviceCookie{cookie} -} - -func (c *Conn) XinputCloseDeviceChecked(DeviceId byte) XinputCloseDeviceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputCloseDeviceRequest(DeviceId), cookie) - return XinputCloseDeviceCookie{cookie} -} - -func (cook XinputCloseDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputCloseDevice -func (c *Conn) xinputCloseDeviceRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - 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] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceMode -// size: 8 -type XinputSetDeviceModeCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceMode(DeviceId byte, Mode byte) XinputSetDeviceModeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceModeRequest(DeviceId, Mode), cookie) - return XinputSetDeviceModeCookie{cookie} -} - -func (c *Conn) XinputSetDeviceModeUnchecked(DeviceId byte, Mode byte) XinputSetDeviceModeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceModeRequest(DeviceId, Mode), cookie) - return XinputSetDeviceModeCookie{cookie} -} - -// Request reply for XinputSetDeviceMode -// size: 32 -type XinputSetDeviceModeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceMode -func (cook XinputSetDeviceModeCookie) Reply() (*XinputSetDeviceModeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceModeReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceMode -func xinputSetDeviceModeReply(buf []byte) *XinputSetDeviceModeReply { - v := new(XinputSetDeviceModeReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceMode -func (c *Conn) xinputSetDeviceModeRequest(DeviceId byte, Mode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = Mode - b += 1 - - b += 2 // padding - - return buf -} - -// Request XinputSelectExtensionEvent -// size: pad((12 + pad((int(NumClasses) * 4)))) -type XinputSelectExtensionEventCookie struct { - *cookie -} - -// Write request to wire for XinputSelectExtensionEvent -func (c *Conn) XinputSelectExtensionEvent(Window Window, NumClasses uint16, Classes []XinputEventClass) XinputSelectExtensionEventCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputSelectExtensionEventRequest(Window, NumClasses, Classes), cookie) - return XinputSelectExtensionEventCookie{cookie} -} - -func (c *Conn) XinputSelectExtensionEventChecked(Window Window, NumClasses uint16, Classes []XinputEventClass) XinputSelectExtensionEventCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputSelectExtensionEventRequest(Window, NumClasses, Classes), cookie) - return XinputSelectExtensionEventCookie{cookie} -} - -func (cook XinputSelectExtensionEventCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSelectExtensionEvent -func (c *Conn) xinputSelectExtensionEventRequest(Window Window, NumClasses uint16, Classes []XinputEventClass) []byte { - size := pad((12 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - 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 - - Put16(buf[b:], NumClasses) - b += 2 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetSelectedExtensionEvents -// size: 8 -type XinputGetSelectedExtensionEventsCookie struct { - *cookie -} - -func (c *Conn) XinputGetSelectedExtensionEvents(Window Window) XinputGetSelectedExtensionEventsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetSelectedExtensionEventsRequest(Window), cookie) - return XinputGetSelectedExtensionEventsCookie{cookie} -} - -func (c *Conn) XinputGetSelectedExtensionEventsUnchecked(Window Window) XinputGetSelectedExtensionEventsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetSelectedExtensionEventsRequest(Window), cookie) - return XinputGetSelectedExtensionEventsCookie{cookie} -} - -// Request reply for XinputGetSelectedExtensionEvents -// size: ((32 + pad((int(NumThisClasses) * 4))) + pad((int(NumAllClasses) * 4))) -type XinputGetSelectedExtensionEventsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumThisClasses uint16 - NumAllClasses uint16 - // padding: 20 bytes - ThisClasses []XinputEventClass // size: pad((int(NumThisClasses) * 4)) - AllClasses []XinputEventClass // size: pad((int(NumAllClasses) * 4)) -} - -// Waits and reads reply data from request XinputGetSelectedExtensionEvents -func (cook XinputGetSelectedExtensionEventsCookie) Reply() (*XinputGetSelectedExtensionEventsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetSelectedExtensionEventsReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetSelectedExtensionEvents -func xinputGetSelectedExtensionEventsReply(buf []byte) *XinputGetSelectedExtensionEventsReply { - v := new(XinputGetSelectedExtensionEventsReply) - 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.NumThisClasses = Get16(buf[b:]) - b += 2 - - v.NumAllClasses = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.ThisClasses = make([]XinputEventClass, v.NumThisClasses) - for i := 0; i < int(v.NumThisClasses); i++ { - v.ThisClasses[i] = XinputEventClass(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.AllClasses = make([]XinputEventClass, v.NumAllClasses) - for i := 0; i < int(v.NumAllClasses); i++ { - v.AllClasses[i] = XinputEventClass(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XinputGetSelectedExtensionEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetSelectedExtensionEvents -func (c *Conn) xinputGetSelectedExtensionEventsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - 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 XinputChangeDeviceDontPropagateList -// size: pad((12 + pad((int(NumClasses) * 4)))) -type XinputChangeDeviceDontPropagateListCookie struct { - *cookie -} - -// Write request to wire for XinputChangeDeviceDontPropagateList -func (c *Conn) XinputChangeDeviceDontPropagateList(Window Window, NumClasses uint16, Mode byte, Classes []XinputEventClass) XinputChangeDeviceDontPropagateListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputChangeDeviceDontPropagateListRequest(Window, NumClasses, Mode, Classes), cookie) - return XinputChangeDeviceDontPropagateListCookie{cookie} -} - -func (c *Conn) XinputChangeDeviceDontPropagateListChecked(Window Window, NumClasses uint16, Mode byte, Classes []XinputEventClass) XinputChangeDeviceDontPropagateListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputChangeDeviceDontPropagateListRequest(Window, NumClasses, Mode, Classes), cookie) - return XinputChangeDeviceDontPropagateListCookie{cookie} -} - -func (cook XinputChangeDeviceDontPropagateListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangeDeviceDontPropagateList -func (c *Conn) xinputChangeDeviceDontPropagateListRequest(Window Window, NumClasses uint16, Mode byte, Classes []XinputEventClass) []byte { - size := pad((12 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - 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 - - Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = Mode - b += 1 - - b += 1 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetDeviceDontPropagateList -// size: 8 -type XinputGetDeviceDontPropagateListCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceDontPropagateList(Window Window) XinputGetDeviceDontPropagateListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceDontPropagateListRequest(Window), cookie) - return XinputGetDeviceDontPropagateListCookie{cookie} -} - -func (c *Conn) XinputGetDeviceDontPropagateListUnchecked(Window Window) XinputGetDeviceDontPropagateListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceDontPropagateListRequest(Window), cookie) - return XinputGetDeviceDontPropagateListCookie{cookie} -} - -// Request reply for XinputGetDeviceDontPropagateList -// size: (32 + pad((int(NumClasses) * 4))) -type XinputGetDeviceDontPropagateListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClasses uint16 - // padding: 22 bytes - Classes []XinputEventClass // size: pad((int(NumClasses) * 4)) -} - -// Waits and reads reply data from request XinputGetDeviceDontPropagateList -func (cook XinputGetDeviceDontPropagateListCookie) Reply() (*XinputGetDeviceDontPropagateListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceDontPropagateListReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceDontPropagateList -func xinputGetDeviceDontPropagateListReply(buf []byte) *XinputGetDeviceDontPropagateListReply { - v := new(XinputGetDeviceDontPropagateListReply) - 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.NumClasses = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Classes = make([]XinputEventClass, v.NumClasses) - for i := 0; i < int(v.NumClasses); i++ { - v.Classes[i] = XinputEventClass(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XinputGetDeviceDontPropagateListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceDontPropagateList -func (c *Conn) xinputGetDeviceDontPropagateListRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 9 // 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 XinputGetDeviceMotionEvents -// size: 16 -type XinputGetDeviceMotionEventsCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceMotionEvents(Start Timestamp, Stop Timestamp, DeviceId byte) XinputGetDeviceMotionEventsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceMotionEventsRequest(Start, Stop, DeviceId), cookie) - return XinputGetDeviceMotionEventsCookie{cookie} -} - -func (c *Conn) XinputGetDeviceMotionEventsUnchecked(Start Timestamp, Stop Timestamp, DeviceId byte) XinputGetDeviceMotionEventsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceMotionEventsRequest(Start, Stop, DeviceId), cookie) - return XinputGetDeviceMotionEventsCookie{cookie} -} - -// Request reply for XinputGetDeviceMotionEvents -// size: 32 -type XinputGetDeviceMotionEventsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumCoords uint32 - NumAxes byte - DeviceMode byte - // padding: 18 bytes -} - -// Waits and reads reply data from request XinputGetDeviceMotionEvents -func (cook XinputGetDeviceMotionEventsCookie) Reply() (*XinputGetDeviceMotionEventsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceMotionEventsReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceMotionEvents -func xinputGetDeviceMotionEventsReply(buf []byte) *XinputGetDeviceMotionEventsReply { - v := new(XinputGetDeviceMotionEventsReply) - 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.NumCoords = Get32(buf[b:]) - b += 4 - - v.NumAxes = buf[b] - b += 1 - - v.DeviceMode = buf[b] - b += 1 - - b += 18 // padding - - return v -} - -func (cook XinputGetDeviceMotionEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceMotionEvents -func (c *Conn) xinputGetDeviceMotionEventsRequest(Start Timestamp, Stop Timestamp, DeviceId byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Start)) - b += 4 - - Put32(buf[b:], uint32(Stop)) - b += 4 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputChangeKeyboardDevice -// size: 8 -type XinputChangeKeyboardDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputChangeKeyboardDevice(DeviceId byte) XinputChangeKeyboardDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputChangeKeyboardDeviceRequest(DeviceId), cookie) - return XinputChangeKeyboardDeviceCookie{cookie} -} - -func (c *Conn) XinputChangeKeyboardDeviceUnchecked(DeviceId byte) XinputChangeKeyboardDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputChangeKeyboardDeviceRequest(DeviceId), cookie) - return XinputChangeKeyboardDeviceCookie{cookie} -} - -// Request reply for XinputChangeKeyboardDevice -// size: 32 -type XinputChangeKeyboardDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputChangeKeyboardDevice -func (cook XinputChangeKeyboardDeviceCookie) Reply() (*XinputChangeKeyboardDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputChangeKeyboardDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputChangeKeyboardDevice -func xinputChangeKeyboardDeviceReply(buf []byte) *XinputChangeKeyboardDeviceReply { - v := new(XinputChangeKeyboardDeviceReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputChangeKeyboardDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangeKeyboardDevice -func (c *Conn) xinputChangeKeyboardDeviceRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputChangePointerDevice -// size: 8 -type XinputChangePointerDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputChangePointerDevice(XAxis byte, YAxis byte, DeviceId byte) XinputChangePointerDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputChangePointerDeviceRequest(XAxis, YAxis, DeviceId), cookie) - return XinputChangePointerDeviceCookie{cookie} -} - -func (c *Conn) XinputChangePointerDeviceUnchecked(XAxis byte, YAxis byte, DeviceId byte) XinputChangePointerDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputChangePointerDeviceRequest(XAxis, YAxis, DeviceId), cookie) - return XinputChangePointerDeviceCookie{cookie} -} - -// Request reply for XinputChangePointerDevice -// size: 32 -type XinputChangePointerDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputChangePointerDevice -func (cook XinputChangePointerDeviceCookie) Reply() (*XinputChangePointerDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputChangePointerDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputChangePointerDevice -func xinputChangePointerDeviceReply(buf []byte) *XinputChangePointerDeviceReply { - v := new(XinputChangePointerDeviceReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputChangePointerDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangePointerDevice -func (c *Conn) xinputChangePointerDeviceRequest(XAxis byte, YAxis byte, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = XAxis - b += 1 - - buf[b] = YAxis - b += 1 - - buf[b] = DeviceId - b += 1 - - b += 1 // padding - - return buf -} - -// Request XinputGrabDevice -// size: pad((20 + pad((int(NumClasses) * 4)))) -type XinputGrabDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputGrabDevice(GrabWindow Window, Time Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []XinputEventClass) XinputGrabDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGrabDeviceRequest(GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) - return XinputGrabDeviceCookie{cookie} -} - -func (c *Conn) XinputGrabDeviceUnchecked(GrabWindow Window, Time Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []XinputEventClass) XinputGrabDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGrabDeviceRequest(GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) - return XinputGrabDeviceCookie{cookie} -} - -// Request reply for XinputGrabDevice -// size: 32 -type XinputGrabDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputGrabDevice -func (cook XinputGrabDeviceCookie) Reply() (*XinputGrabDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGrabDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputGrabDevice -func xinputGrabDeviceReply(buf []byte) *XinputGrabDeviceReply { - v := new(XinputGrabDeviceReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputGrabDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGrabDevice -func (c *Conn) xinputGrabDeviceRequest(GrabWindow Window, Time Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []XinputEventClass) []byte { - size := pad((20 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = DeviceId - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputUngrabDevice -// size: 12 -type XinputUngrabDeviceCookie struct { - *cookie -} - -// Write request to wire for XinputUngrabDevice -func (c *Conn) XinputUngrabDevice(Time Timestamp, DeviceId byte) XinputUngrabDeviceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputUngrabDeviceRequest(Time, DeviceId), cookie) - return XinputUngrabDeviceCookie{cookie} -} - -func (c *Conn) XinputUngrabDeviceChecked(Time Timestamp, DeviceId byte) XinputUngrabDeviceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputUngrabDeviceRequest(Time, DeviceId), cookie) - return XinputUngrabDeviceCookie{cookie} -} - -func (cook XinputUngrabDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputUngrabDevice -func (c *Conn) xinputUngrabDeviceRequest(Time Timestamp, DeviceId byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputGrabDeviceKey -// size: pad((20 + pad((int(NumClasses) * 4)))) -type XinputGrabDeviceKeyCookie struct { - *cookie -} - -// Write request to wire for XinputGrabDeviceKey -func (c *Conn) XinputGrabDeviceKey(GrabWindow Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []XinputEventClass) XinputGrabDeviceKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputGrabDeviceKeyRequest(GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) - return XinputGrabDeviceKeyCookie{cookie} -} - -func (c *Conn) XinputGrabDeviceKeyChecked(GrabWindow Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []XinputEventClass) XinputGrabDeviceKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputGrabDeviceKeyRequest(GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) - return XinputGrabDeviceKeyCookie{cookie} -} - -func (cook XinputGrabDeviceKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGrabDeviceKey -func (c *Conn) xinputGrabDeviceKeyRequest(GrabWindow Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []XinputEventClass) []byte { - size := pad((20 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], NumClasses) - b += 2 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputUngrabDeviceKey -// size: 16 -type XinputUngrabDeviceKeyCookie struct { - *cookie -} - -// Write request to wire for XinputUngrabDeviceKey -func (c *Conn) XinputUngrabDeviceKey(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) XinputUngrabDeviceKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputUngrabDeviceKeyRequest(GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return XinputUngrabDeviceKeyCookie{cookie} -} - -func (c *Conn) XinputUngrabDeviceKeyChecked(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) XinputUngrabDeviceKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputUngrabDeviceKeyRequest(GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return XinputUngrabDeviceKeyCookie{cookie} -} - -func (cook XinputUngrabDeviceKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputUngrabDeviceKey -func (c *Conn) xinputUngrabDeviceKeyRequest(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - return buf -} - -// Request XinputGrabDeviceButton -// size: pad((20 + pad((int(NumClasses) * 4)))) -type XinputGrabDeviceButtonCookie struct { - *cookie -} - -// Write request to wire for XinputGrabDeviceButton -func (c *Conn) XinputGrabDeviceButton(GrabWindow Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []XinputEventClass) XinputGrabDeviceButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputGrabDeviceButtonRequest(GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return XinputGrabDeviceButtonCookie{cookie} -} - -func (c *Conn) XinputGrabDeviceButtonChecked(GrabWindow Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []XinputEventClass) XinputGrabDeviceButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputGrabDeviceButtonRequest(GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return XinputGrabDeviceButtonCookie{cookie} -} - -func (cook XinputGrabDeviceButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGrabDeviceButton -func (c *Conn) xinputGrabDeviceButtonRequest(GrabWindow Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []XinputEventClass) []byte { - size := pad((20 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - buf[b] = GrabbedDevice - b += 1 - - buf[b] = ModifierDevice - b += 1 - - Put16(buf[b:], NumClasses) - b += 2 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = OwnerEvents - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputUngrabDeviceButton -// size: 16 -type XinputUngrabDeviceButtonCookie struct { - *cookie -} - -// Write request to wire for XinputUngrabDeviceButton -func (c *Conn) XinputUngrabDeviceButton(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) XinputUngrabDeviceButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputUngrabDeviceButtonRequest(GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return XinputUngrabDeviceButtonCookie{cookie} -} - -func (c *Conn) XinputUngrabDeviceButtonChecked(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) XinputUngrabDeviceButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputUngrabDeviceButtonRequest(GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return XinputUngrabDeviceButtonCookie{cookie} -} - -func (cook XinputUngrabDeviceButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputUngrabDeviceButton -func (c *Conn) xinputUngrabDeviceButtonRequest(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - return buf -} - -// Request XinputAllowDeviceEvents -// size: 12 -type XinputAllowDeviceEventsCookie struct { - *cookie -} - -// Write request to wire for XinputAllowDeviceEvents -func (c *Conn) XinputAllowDeviceEvents(Time Timestamp, Mode byte, DeviceId byte) XinputAllowDeviceEventsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputAllowDeviceEventsRequest(Time, Mode, DeviceId), cookie) - return XinputAllowDeviceEventsCookie{cookie} -} - -func (c *Conn) XinputAllowDeviceEventsChecked(Time Timestamp, Mode byte, DeviceId byte) XinputAllowDeviceEventsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputAllowDeviceEventsRequest(Time, Mode, DeviceId), cookie) - return XinputAllowDeviceEventsCookie{cookie} -} - -func (cook XinputAllowDeviceEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputAllowDeviceEvents -func (c *Conn) xinputAllowDeviceEventsRequest(Time Timestamp, Mode byte, DeviceId byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = Mode - b += 1 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputGetDeviceFocus -// size: 8 -type XinputGetDeviceFocusCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceFocus(DeviceId byte) XinputGetDeviceFocusCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceFocusRequest(DeviceId), cookie) - return XinputGetDeviceFocusCookie{cookie} -} - -func (c *Conn) XinputGetDeviceFocusUnchecked(DeviceId byte) XinputGetDeviceFocusCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceFocusRequest(DeviceId), cookie) - return XinputGetDeviceFocusCookie{cookie} -} - -// Request reply for XinputGetDeviceFocus -// size: 32 -type XinputGetDeviceFocusReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Focus Window - Time Timestamp - RevertTo byte - // padding: 15 bytes -} - -// Waits and reads reply data from request XinputGetDeviceFocus -func (cook XinputGetDeviceFocusCookie) Reply() (*XinputGetDeviceFocusReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceFocusReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceFocus -func xinputGetDeviceFocusReply(buf []byte) *XinputGetDeviceFocusReply { - v := new(XinputGetDeviceFocusReply) - 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.Focus = Window(Get32(buf[b:])) - b += 4 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.RevertTo = buf[b] - b += 1 - - b += 15 // padding - - return v -} - -func (cook XinputGetDeviceFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceFocus -func (c *Conn) xinputGetDeviceFocusRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceFocus -// size: 16 -type XinputSetDeviceFocusCookie struct { - *cookie -} - -// Write request to wire for XinputSetDeviceFocus -func (c *Conn) XinputSetDeviceFocus(Focus Window, Time Timestamp, RevertTo byte, DeviceId byte) XinputSetDeviceFocusCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputSetDeviceFocusRequest(Focus, Time, RevertTo, DeviceId), cookie) - return XinputSetDeviceFocusCookie{cookie} -} - -func (c *Conn) XinputSetDeviceFocusChecked(Focus Window, Time Timestamp, RevertTo byte, DeviceId byte) XinputSetDeviceFocusCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputSetDeviceFocusRequest(Focus, Time, RevertTo, DeviceId), cookie) - return XinputSetDeviceFocusCookie{cookie} -} - -func (cook XinputSetDeviceFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceFocus -func (c *Conn) xinputSetDeviceFocusRequest(Focus Window, Time Timestamp, RevertTo byte, DeviceId byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Focus)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = RevertTo - b += 1 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputGetFeedbackControl -// size: 8 -type XinputGetFeedbackControlCookie struct { - *cookie -} - -func (c *Conn) XinputGetFeedbackControl(DeviceId byte) XinputGetFeedbackControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetFeedbackControlRequest(DeviceId), cookie) - return XinputGetFeedbackControlCookie{cookie} -} - -func (c *Conn) XinputGetFeedbackControlUnchecked(DeviceId byte) XinputGetFeedbackControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetFeedbackControlRequest(DeviceId), cookie) - return XinputGetFeedbackControlCookie{cookie} -} - -// Request reply for XinputGetFeedbackControl -// size: 32 -type XinputGetFeedbackControlReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFeedback uint16 - // padding: 22 bytes -} - -// Waits and reads reply data from request XinputGetFeedbackControl -func (cook XinputGetFeedbackControlCookie) Reply() (*XinputGetFeedbackControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetFeedbackControlReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetFeedbackControl -func xinputGetFeedbackControlReply(buf []byte) *XinputGetFeedbackControlReply { - v := new(XinputGetFeedbackControlReply) - 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.NumFeedback = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -func (cook XinputGetFeedbackControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetFeedbackControl -func (c *Conn) xinputGetFeedbackControlRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputGetDeviceKeyMapping -// size: 8 -type XinputGetDeviceKeyMappingCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceKeyMapping(DeviceId byte, FirstKeycode XinputKeyCode, Count byte) XinputGetDeviceKeyMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceKeyMappingRequest(DeviceId, FirstKeycode, Count), cookie) - return XinputGetDeviceKeyMappingCookie{cookie} -} - -func (c *Conn) XinputGetDeviceKeyMappingUnchecked(DeviceId byte, FirstKeycode XinputKeyCode, Count byte) XinputGetDeviceKeyMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceKeyMappingRequest(DeviceId, FirstKeycode, Count), cookie) - return XinputGetDeviceKeyMappingCookie{cookie} -} - -// Request reply for XinputGetDeviceKeyMapping -// size: (32 + pad((int(Length) * 4))) -type XinputGetDeviceKeyMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - KeysymsPerKeycode byte - // padding: 23 bytes - Keysyms []Keysym // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request XinputGetDeviceKeyMapping -func (cook XinputGetDeviceKeyMappingCookie) Reply() (*XinputGetDeviceKeyMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceKeyMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceKeyMapping -func xinputGetDeviceKeyMappingReply(buf []byte) *XinputGetDeviceKeyMappingReply { - v := new(XinputGetDeviceKeyMappingReply) - 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.KeysymsPerKeycode = buf[b] - b += 1 - - b += 23 // padding - - v.Keysyms = make([]Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XinputGetDeviceKeyMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceKeyMapping -func (c *Conn) xinputGetDeviceKeyMappingRequest(DeviceId byte, FirstKeycode XinputKeyCode, Count byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - - return buf -} - -// Request XinputChangeDeviceKeyMapping -// size: pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) -type XinputChangeDeviceKeyMappingCookie struct { - *cookie -} - -// Write request to wire for XinputChangeDeviceKeyMapping -func (c *Conn) XinputChangeDeviceKeyMapping(DeviceId byte, FirstKeycode XinputKeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []Keysym) XinputChangeDeviceKeyMappingCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputChangeDeviceKeyMappingRequest(DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) - return XinputChangeDeviceKeyMappingCookie{cookie} -} - -func (c *Conn) XinputChangeDeviceKeyMappingChecked(DeviceId byte, FirstKeycode XinputKeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []Keysym) XinputChangeDeviceKeyMappingCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputChangeDeviceKeyMappingRequest(DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) - return XinputChangeDeviceKeyMappingCookie{cookie} -} - -func (cook XinputChangeDeviceKeyMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangeDeviceKeyMapping -func (c *Conn) xinputChangeDeviceKeyMappingRequest(DeviceId byte, FirstKeycode XinputKeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []Keysym) []byte { - size := pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = KeysymsPerKeycode - b += 1 - - buf[b] = KeycodeCount - b += 1 - - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetDeviceModifierMapping -// size: 8 -type XinputGetDeviceModifierMappingCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceModifierMapping(DeviceId byte) XinputGetDeviceModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceModifierMappingRequest(DeviceId), cookie) - return XinputGetDeviceModifierMappingCookie{cookie} -} - -func (c *Conn) XinputGetDeviceModifierMappingUnchecked(DeviceId byte) XinputGetDeviceModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceModifierMappingRequest(DeviceId), cookie) - return XinputGetDeviceModifierMappingCookie{cookie} -} - -// Request reply for XinputGetDeviceModifierMapping -// size: (32 + pad(((int(KeycodesPerModifier) * 8) * 1))) -type XinputGetDeviceModifierMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - KeycodesPerModifier byte - // padding: 23 bytes - Keymaps []byte // size: pad(((int(KeycodesPerModifier) * 8) * 1)) -} - -// Waits and reads reply data from request XinputGetDeviceModifierMapping -func (cook XinputGetDeviceModifierMappingCookie) Reply() (*XinputGetDeviceModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceModifierMapping -func xinputGetDeviceModifierMappingReply(buf []byte) *XinputGetDeviceModifierMappingReply { - v := new(XinputGetDeviceModifierMappingReply) - 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.KeycodesPerModifier = buf[b] - b += 1 - - b += 23 // padding - - v.Keymaps = make([]byte, (int(v.KeycodesPerModifier) * 8)) - copy(v.Keymaps[:(int(v.KeycodesPerModifier)*8)], buf[b:]) - b += pad(int((int(v.KeycodesPerModifier) * 8))) - - return v -} - -func (cook XinputGetDeviceModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceModifierMapping -func (c *Conn) xinputGetDeviceModifierMappingRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceModifierMapping -// size: pad((7 + pad(((int(KeycodesPerModifier) * 8) * 1)))) -type XinputSetDeviceModifierMappingCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceModifierMapping(DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) XinputSetDeviceModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceModifierMappingRequest(DeviceId, KeycodesPerModifier, Keymaps), cookie) - return XinputSetDeviceModifierMappingCookie{cookie} -} - -func (c *Conn) XinputSetDeviceModifierMappingUnchecked(DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) XinputSetDeviceModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceModifierMappingRequest(DeviceId, KeycodesPerModifier, Keymaps), cookie) - return XinputSetDeviceModifierMappingCookie{cookie} -} - -// Request reply for XinputSetDeviceModifierMapping -// size: 32 -type XinputSetDeviceModifierMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceModifierMapping -func (cook XinputSetDeviceModifierMappingCookie) Reply() (*XinputSetDeviceModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceModifierMapping -func xinputSetDeviceModifierMappingReply(buf []byte) *XinputSetDeviceModifierMappingReply { - v := new(XinputSetDeviceModifierMappingReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceModifierMapping -func (c *Conn) xinputSetDeviceModifierMappingRequest(DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { - size := pad((7 + pad(((int(KeycodesPerModifier) * 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = KeycodesPerModifier - b += 1 - - b += 1 // padding - - copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) - b += pad(int((int(KeycodesPerModifier) * 8))) - - return buf -} - -// Request XinputGetDeviceButtonMapping -// size: 8 -type XinputGetDeviceButtonMappingCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceButtonMapping(DeviceId byte) XinputGetDeviceButtonMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceButtonMappingRequest(DeviceId), cookie) - return XinputGetDeviceButtonMappingCookie{cookie} -} - -func (c *Conn) XinputGetDeviceButtonMappingUnchecked(DeviceId byte) XinputGetDeviceButtonMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceButtonMappingRequest(DeviceId), cookie) - return XinputGetDeviceButtonMappingCookie{cookie} -} - -// Request reply for XinputGetDeviceButtonMapping -// size: (32 + pad((int(MapSize) * 1))) -type XinputGetDeviceButtonMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MapSize byte - // padding: 23 bytes - Map []byte // size: pad((int(MapSize) * 1)) -} - -// Waits and reads reply data from request XinputGetDeviceButtonMapping -func (cook XinputGetDeviceButtonMappingCookie) Reply() (*XinputGetDeviceButtonMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceButtonMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceButtonMapping -func xinputGetDeviceButtonMappingReply(buf []byte) *XinputGetDeviceButtonMappingReply { - v := new(XinputGetDeviceButtonMappingReply) - 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.MapSize = buf[b] - b += 1 - - b += 23 // padding - - v.Map = make([]byte, v.MapSize) - copy(v.Map[:v.MapSize], buf[b:]) - b += pad(int(v.MapSize)) - - return v -} - -func (cook XinputGetDeviceButtonMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceButtonMapping -func (c *Conn) xinputGetDeviceButtonMappingRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceButtonMapping -// size: pad((8 + pad((int(MapSize) * 1)))) -type XinputSetDeviceButtonMappingCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceButtonMapping(DeviceId byte, MapSize byte, Map []byte) XinputSetDeviceButtonMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceButtonMappingRequest(DeviceId, MapSize, Map), cookie) - return XinputSetDeviceButtonMappingCookie{cookie} -} - -func (c *Conn) XinputSetDeviceButtonMappingUnchecked(DeviceId byte, MapSize byte, Map []byte) XinputSetDeviceButtonMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceButtonMappingRequest(DeviceId, MapSize, Map), cookie) - return XinputSetDeviceButtonMappingCookie{cookie} -} - -// Request reply for XinputSetDeviceButtonMapping -// size: 32 -type XinputSetDeviceButtonMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceButtonMapping -func (cook XinputSetDeviceButtonMappingCookie) Reply() (*XinputSetDeviceButtonMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceButtonMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceButtonMapping -func xinputSetDeviceButtonMappingReply(buf []byte) *XinputSetDeviceButtonMappingReply { - v := new(XinputSetDeviceButtonMappingReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceButtonMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceButtonMapping -func (c *Conn) xinputSetDeviceButtonMappingRequest(DeviceId byte, MapSize byte, Map []byte) []byte { - size := pad((8 + pad((int(MapSize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = MapSize - b += 1 - - b += 2 // padding - - copy(buf[b:], Map[:MapSize]) - b += pad(int(MapSize)) - - return buf -} - -// Request XinputQueryDeviceState -// size: 8 -type XinputQueryDeviceStateCookie struct { - *cookie -} - -func (c *Conn) XinputQueryDeviceState(DeviceId byte) XinputQueryDeviceStateCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputQueryDeviceStateRequest(DeviceId), cookie) - return XinputQueryDeviceStateCookie{cookie} -} - -func (c *Conn) XinputQueryDeviceStateUnchecked(DeviceId byte) XinputQueryDeviceStateCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputQueryDeviceStateRequest(DeviceId), cookie) - return XinputQueryDeviceStateCookie{cookie} -} - -// Request reply for XinputQueryDeviceState -// size: 32 -type XinputQueryDeviceStateReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClasses byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputQueryDeviceState -func (cook XinputQueryDeviceStateCookie) Reply() (*XinputQueryDeviceStateReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputQueryDeviceStateReply(buf), nil -} - -// Read reply into structure from buffer for XinputQueryDeviceState -func xinputQueryDeviceStateReply(buf []byte) *XinputQueryDeviceStateReply { - v := new(XinputQueryDeviceStateReply) - 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.NumClasses = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputQueryDeviceStateCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputQueryDeviceState -func (c *Conn) xinputQueryDeviceStateRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSendExtensionEvent -// size: pad(((16 + pad(((int(NumEvents) * 32) * 1))) + pad((int(NumClasses) * 4)))) -type XinputSendExtensionEventCookie struct { - *cookie -} - -// Write request to wire for XinputSendExtensionEvent -func (c *Conn) XinputSendExtensionEvent(Destination Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []XinputEventClass) XinputSendExtensionEventCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputSendExtensionEventRequest(Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return XinputSendExtensionEventCookie{cookie} -} - -func (c *Conn) XinputSendExtensionEventChecked(Destination Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []XinputEventClass) XinputSendExtensionEventCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputSendExtensionEventRequest(Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return XinputSendExtensionEventCookie{cookie} -} - -func (cook XinputSendExtensionEventCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSendExtensionEvent -func (c *Conn) xinputSendExtensionEventRequest(Destination Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []XinputEventClass) []byte { - size := pad(((16 + pad(((int(NumEvents) * 32) * 1))) + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 31 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - buf[b] = DeviceId - b += 1 - - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = NumEvents - b += 1 - - b += 3 // padding - - copy(buf[b:], Events[:(int(NumEvents)*32)]) - b += pad(int((int(NumEvents) * 32))) - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputDeviceBell -// size: 8 -type XinputDeviceBellCookie struct { - *cookie -} - -// Write request to wire for XinputDeviceBell -func (c *Conn) XinputDeviceBell(DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) XinputDeviceBellCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputDeviceBellRequest(DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return XinputDeviceBellCookie{cookie} -} - -func (c *Conn) XinputDeviceBellChecked(DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) XinputDeviceBellCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputDeviceBellRequest(DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return XinputDeviceBellCookie{cookie} -} - -func (cook XinputDeviceBellCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputDeviceBell -func (c *Conn) xinputDeviceBellRequest(DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 32 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = FeedbackId - b += 1 - - buf[b] = FeedbackClass - b += 1 - - buf[b] = byte(Percent) - b += 1 - - return buf -} - -// Request XinputSetDeviceValuators -// size: pad((8 + pad((int(NumValuators) * 4)))) -type XinputSetDeviceValuatorsCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceValuators(DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) XinputSetDeviceValuatorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceValuatorsRequest(DeviceId, FirstValuator, NumValuators, Valuators), cookie) - return XinputSetDeviceValuatorsCookie{cookie} -} - -func (c *Conn) XinputSetDeviceValuatorsUnchecked(DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) XinputSetDeviceValuatorsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceValuatorsRequest(DeviceId, FirstValuator, NumValuators, Valuators), cookie) - return XinputSetDeviceValuatorsCookie{cookie} -} - -// Request reply for XinputSetDeviceValuators -// size: 32 -type XinputSetDeviceValuatorsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceValuators -func (cook XinputSetDeviceValuatorsCookie) Reply() (*XinputSetDeviceValuatorsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceValuatorsReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceValuators -func xinputSetDeviceValuatorsReply(buf []byte) *XinputSetDeviceValuatorsReply { - v := new(XinputSetDeviceValuatorsReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceValuatorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceValuators -func (c *Conn) xinputSetDeviceValuatorsRequest(DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { - size := pad((8 + pad((int(NumValuators) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 33 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = FirstValuator - b += 1 - - buf[b] = NumValuators - b += 1 - - b += 1 // padding - - for i := 0; i < int(NumValuators); i++ { - Put32(buf[b:], uint32(Valuators[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetDeviceControl -// size: 8 -type XinputGetDeviceControlCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceControl(ControlId uint16, DeviceId byte) XinputGetDeviceControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceControlRequest(ControlId, DeviceId), cookie) - return XinputGetDeviceControlCookie{cookie} -} - -func (c *Conn) XinputGetDeviceControlUnchecked(ControlId uint16, DeviceId byte) XinputGetDeviceControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceControlRequest(ControlId, DeviceId), cookie) - return XinputGetDeviceControlCookie{cookie} -} - -// Request reply for XinputGetDeviceControl -// size: 32 -type XinputGetDeviceControlReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputGetDeviceControl -func (cook XinputGetDeviceControlCookie) Reply() (*XinputGetDeviceControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceControlReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceControl -func xinputGetDeviceControlReply(buf []byte) *XinputGetDeviceControlReply { - v := new(XinputGetDeviceControlReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputGetDeviceControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceControl -func (c *Conn) xinputGetDeviceControlRequest(ControlId uint16, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 34 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], ControlId) - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 1 // padding - - return buf -} diff --git a/nexgb/auto_xprint.go b/nexgb/auto_xprint.go deleted file mode 100644 index cab145e..0000000 --- a/nexgb/auto_xprint.go +++ /dev/null @@ -1,2210 +0,0 @@ -package xgb - -/* - This file was generated by xprint.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" - -// XprintInit must be called before using the XpExtension extension. -func (c *Conn) XprintInit() error { - reply, err := c.QueryExtension(11, "XpExtension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XpExtension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XpExtension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XpExtension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XpExtension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XpExtension"] = make(map[int]newEventFun) - newExtErrorFuncs["XpExtension"] = 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 ( - XprintGetDocFinished = 0 - XprintGetDocSecondConsumer = 1 -) - -const ( - XprintEvMaskNoEventMask = 0 - XprintEvMaskPrintMask = 1 - XprintEvMaskAttributeMask = 2 -) - -const ( - XprintDetailStartJobNotify = 1 - XprintDetailEndJobNotify = 2 - XprintDetailStartDocNotify = 3 - XprintDetailEndDocNotify = 4 - XprintDetailStartPageNotify = 5 - XprintDetailEndPageNotify = 6 -) - -const ( - XprintAttrJobAttr = 1 - XprintAttrDocAttr = 2 - XprintAttrPageAttr = 3 - XprintAttrPrinterAttr = 4 - XprintAttrServerAttr = 5 - XprintAttrMediumAttr = 6 - XprintAttrSpoolerAttr = 7 -) - -type XprintPcontext uint32 - -func (c *Conn) NewXprintPcontextId() (XprintPcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XprintPcontext(id), nil -} - -type XprintString8 byte - -// 'XprintPrinter' struct definition -// Size: (((4 + pad((int(NameLen) * 1))) + 4) + pad((int(DescLen) * 1))) -type XprintPrinter struct { - NameLen uint32 - Name []XprintString8 // size: pad((int(NameLen) * 1)) - DescLen uint32 - Description []XprintString8 // size: pad((int(DescLen) * 1)) -} - -// Struct read XprintPrinter -func ReadXprintPrinter(buf []byte, v *XprintPrinter) int { - b := 0 - - v.NameLen = Get32(buf[b:]) - b += 4 - - v.Name = make([]XprintString8, v.NameLen) - for i := 0; i < int(v.NameLen); i++ { - v.Name[i] = XprintString8(buf[b]) - b += 1 - } - b = pad(b) - - v.DescLen = Get32(buf[b:]) - b += 4 - - v.Description = make([]XprintString8, v.DescLen) - for i := 0; i < int(v.DescLen); i++ { - v.Description[i] = XprintString8(buf[b]) - b += 1 - } - b = pad(b) - - return b -} - -// Struct list read XprintPrinter -func ReadXprintPrinterList(buf []byte, dest []XprintPrinter) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XprintPrinter{} - b += ReadXprintPrinter(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XprintPrinter -func (v XprintPrinter) Bytes() []byte { - buf := make([]byte, (((4 + pad((int(v.NameLen) * 1))) + 4) + pad((int(v.DescLen) * 1)))) - b := 0 - - Put32(buf[b:], v.NameLen) - b += 4 - - for i := 0; i < int(v.NameLen); i++ { - buf[b] = byte(v.Name[i]) - b += 1 - } - b = pad(b) - - Put32(buf[b:], v.DescLen) - b += 4 - - for i := 0; i < int(v.DescLen); i++ { - buf[b] = byte(v.Description[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Write struct list XprintPrinter -func XprintPrinterListBytes(buf []byte, list []XprintPrinter) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XprintPrinter -func XprintPrinterListSize(list []XprintPrinter) int { - size := 0 - for _, item := range list { - size += (((4 + pad((int(item.NameLen) * 1))) + 4) + pad((int(item.DescLen) * 1))) - } - return size -} - -// Event definition XprintNotify (0) -// Size: 32 - -const XprintNotify = 0 - -type XprintNotifyEvent struct { - Sequence uint16 - Detail byte - Context XprintPcontext - Cancel bool -} - -// Event read XprintNotify -func NewXprintNotifyEvent(buf []byte) Event { - v := XprintNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Context = XprintPcontext(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.Cancel = true - } else { - v.Cancel = false - } - b += 1 - - return v -} - -// Event write XprintNotify -func (v XprintNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Context)) - b += 4 - - if v.Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -func (v XprintNotifyEvent) ImplementsEvent() {} - -func (v XprintNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XprintNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Context: %d", v.Context)) - fieldVals = append(fieldVals, sprintf("Cancel: %t", v.Cancel)) - return "XprintNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XpExtension"][0] = NewXprintNotifyEvent -} - -// Event definition XprintAttributNotify (1) -// Size: 32 - -const XprintAttributNotify = 1 - -type XprintAttributNotifyEvent struct { - Sequence uint16 - Detail byte - Context XprintPcontext -} - -// Event read XprintAttributNotify -func NewXprintAttributNotifyEvent(buf []byte) Event { - v := XprintAttributNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Context = XprintPcontext(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write XprintAttributNotify -func (v XprintAttributNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Context)) - b += 4 - - return buf -} - -func (v XprintAttributNotifyEvent) ImplementsEvent() {} - -func (v XprintAttributNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XprintAttributNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Context: %d", v.Context)) - return "XprintAttributNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XpExtension"][1] = NewXprintAttributNotifyEvent -} - -// Error definition XprintBadContext (0) -// Size: 32 - -const BadXprintBadContext = 0 - -type XprintBadContextError struct { - Sequence uint16 - NiceName string -} - -// Error read XprintBadContext -func NewXprintBadContextError(buf []byte) Error { - v := XprintBadContextError{} - v.NiceName = "XprintBadContext" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XprintBadContextError) ImplementsError() {} - -func (err XprintBadContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err XprintBadContextError) BadId() uint32 { - return 0 -} - -func (err XprintBadContextError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXprintBadContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XpExtension"][0] = NewXprintBadContextError -} - -// Error definition XprintBadSequence (1) -// Size: 32 - -const BadXprintBadSequence = 1 - -type XprintBadSequenceError struct { - Sequence uint16 - NiceName string -} - -// Error read XprintBadSequence -func NewXprintBadSequenceError(buf []byte) Error { - v := XprintBadSequenceError{} - v.NiceName = "XprintBadSequence" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XprintBadSequenceError) ImplementsError() {} - -func (err XprintBadSequenceError) SequenceId() uint16 { - return err.Sequence -} - -func (err XprintBadSequenceError) BadId() uint32 { - return 0 -} - -func (err XprintBadSequenceError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXprintBadSequence {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XpExtension"][1] = NewXprintBadSequenceError -} - -// Request XprintPrintQueryVersion -// size: 4 -type XprintPrintQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XprintPrintQueryVersion() XprintPrintQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintQueryVersionRequest(), cookie) - return XprintPrintQueryVersionCookie{cookie} -} - -func (c *Conn) XprintPrintQueryVersionUnchecked() XprintPrintQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintQueryVersionRequest(), cookie) - return XprintPrintQueryVersionCookie{cookie} -} - -// Request reply for XprintPrintQueryVersion -// size: 12 -type XprintPrintQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request XprintPrintQueryVersion -func (cook XprintPrintQueryVersionCookie) Reply() (*XprintPrintQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintQueryVersion -func xprintPrintQueryVersionReply(buf []byte) *XprintPrintQueryVersionReply { - v := new(XprintPrintQueryVersionReply) - 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 XprintPrintQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintQueryVersion -func (c *Conn) xprintPrintQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - 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 XprintPrintGetPrinterList -// size: pad(((12 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) -type XprintPrintGetPrinterListCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetPrinterList(PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintPrintGetPrinterListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetPrinterListRequest(PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintPrintGetPrinterListCookie{cookie} -} - -func (c *Conn) XprintPrintGetPrinterListUnchecked(PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintPrintGetPrinterListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetPrinterListRequest(PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintPrintGetPrinterListCookie{cookie} -} - -// Request reply for XprintPrintGetPrinterList -// size: (32 + XprintPrinterListSize(Printers)) -type XprintPrintGetPrinterListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Printers []XprintPrinter // size: XprintPrinterListSize(Printers) -} - -// Waits and reads reply data from request XprintPrintGetPrinterList -func (cook XprintPrintGetPrinterListCookie) Reply() (*XprintPrintGetPrinterListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetPrinterListReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetPrinterList -func xprintPrintGetPrinterListReply(buf []byte) *XprintPrintGetPrinterListReply { - v := new(XprintPrintGetPrinterListReply) - 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.ListCount = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Printers = make([]XprintPrinter, v.ListCount) - b += ReadXprintPrinterList(buf[b:], v.Printers) - - return v -} - -func (cook XprintPrintGetPrinterListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetPrinterList -func (c *Conn) xprintPrintGetPrinterListRequest(PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) []byte { - size := pad(((12 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - 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:], PrinterNameLen) - b += 4 - - Put32(buf[b:], LocaleLen) - b += 4 - - for i := 0; i < int(PrinterNameLen); i++ { - buf[b] = byte(PrinterName[i]) - b += 1 - } - b = pad(b) - - for i := 0; i < int(LocaleLen); i++ { - buf[b] = byte(Locale[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintRehashPrinterList -// size: 4 -type XprintPrintRehashPrinterListCookie struct { - *cookie -} - -// Write request to wire for XprintPrintRehashPrinterList -func (c *Conn) XprintPrintRehashPrinterList() XprintPrintRehashPrinterListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintRehashPrinterListRequest(), cookie) - return XprintPrintRehashPrinterListCookie{cookie} -} - -func (c *Conn) XprintPrintRehashPrinterListChecked() XprintPrintRehashPrinterListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintRehashPrinterListRequest(), cookie) - return XprintPrintRehashPrinterListCookie{cookie} -} - -func (cook XprintPrintRehashPrinterListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintRehashPrinterList -func (c *Conn) xprintPrintRehashPrinterListRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintCreateContext -// size: pad(((16 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) -type XprintCreateContextCookie struct { - *cookie -} - -// Write request to wire for XprintCreateContext -func (c *Conn) XprintCreateContext(ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintCreateContextRequest(ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintCreateContextCookie{cookie} -} - -func (c *Conn) XprintCreateContextChecked(ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintCreateContextRequest(ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintCreateContextCookie{cookie} -} - -func (cook XprintCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintCreateContext -func (c *Conn) xprintCreateContextRequest(ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) []byte { - size := pad(((16 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - 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:], ContextId) - b += 4 - - Put32(buf[b:], PrinterNameLen) - b += 4 - - Put32(buf[b:], LocaleLen) - b += 4 - - for i := 0; i < int(PrinterNameLen); i++ { - buf[b] = byte(PrinterName[i]) - b += 1 - } - b = pad(b) - - for i := 0; i < int(LocaleLen); i++ { - buf[b] = byte(Locale[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintSetContext -// size: 8 -type XprintPrintSetContextCookie struct { - *cookie -} - -// Write request to wire for XprintPrintSetContext -func (c *Conn) XprintPrintSetContext(Context uint32) XprintPrintSetContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintSetContextRequest(Context), cookie) - return XprintPrintSetContextCookie{cookie} -} - -func (c *Conn) XprintPrintSetContextChecked(Context uint32) XprintPrintSetContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintSetContextRequest(Context), cookie) - return XprintPrintSetContextCookie{cookie} -} - -func (cook XprintPrintSetContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSetContext -func (c *Conn) xprintPrintSetContextRequest(Context uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - 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:], Context) - b += 4 - - return buf -} - -// Request XprintPrintGetContext -// size: 4 -type XprintPrintGetContextCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetContext() XprintPrintGetContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetContextRequest(), cookie) - return XprintPrintGetContextCookie{cookie} -} - -func (c *Conn) XprintPrintGetContextUnchecked() XprintPrintGetContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetContextRequest(), cookie) - return XprintPrintGetContextCookie{cookie} -} - -// Request reply for XprintPrintGetContext -// size: 12 -type XprintPrintGetContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Context uint32 -} - -// Waits and reads reply data from request XprintPrintGetContext -func (cook XprintPrintGetContextCookie) Reply() (*XprintPrintGetContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetContextReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetContext -func xprintPrintGetContextReply(buf []byte) *XprintPrintGetContextReply { - v := new(XprintPrintGetContextReply) - 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.Context = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook XprintPrintGetContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetContext -func (c *Conn) xprintPrintGetContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - 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 XprintPrintDestroyContext -// size: 8 -type XprintPrintDestroyContextCookie struct { - *cookie -} - -// Write request to wire for XprintPrintDestroyContext -func (c *Conn) XprintPrintDestroyContext(Context uint32) XprintPrintDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintDestroyContextRequest(Context), cookie) - return XprintPrintDestroyContextCookie{cookie} -} - -func (c *Conn) XprintPrintDestroyContextChecked(Context uint32) XprintPrintDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintDestroyContextRequest(Context), cookie) - return XprintPrintDestroyContextCookie{cookie} -} - -func (cook XprintPrintDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintDestroyContext -func (c *Conn) xprintPrintDestroyContextRequest(Context uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - 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:], Context) - b += 4 - - return buf -} - -// Request XprintPrintGetScreenOfContext -// size: 4 -type XprintPrintGetScreenOfContextCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetScreenOfContext() XprintPrintGetScreenOfContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetScreenOfContextRequest(), cookie) - return XprintPrintGetScreenOfContextCookie{cookie} -} - -func (c *Conn) XprintPrintGetScreenOfContextUnchecked() XprintPrintGetScreenOfContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetScreenOfContextRequest(), cookie) - return XprintPrintGetScreenOfContextCookie{cookie} -} - -// Request reply for XprintPrintGetScreenOfContext -// size: 12 -type XprintPrintGetScreenOfContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Root Window -} - -// Waits and reads reply data from request XprintPrintGetScreenOfContext -func (cook XprintPrintGetScreenOfContextCookie) Reply() (*XprintPrintGetScreenOfContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetScreenOfContextReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetScreenOfContext -func xprintPrintGetScreenOfContextReply(buf []byte) *XprintPrintGetScreenOfContextReply { - v := new(XprintPrintGetScreenOfContextReply) - 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.Root = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook XprintPrintGetScreenOfContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetScreenOfContext -func (c *Conn) xprintPrintGetScreenOfContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintPrintStartJob -// size: 8 -type XprintPrintStartJobCookie struct { - *cookie -} - -// Write request to wire for XprintPrintStartJob -func (c *Conn) XprintPrintStartJob(OutputMode byte) XprintPrintStartJobCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintStartJobRequest(OutputMode), cookie) - return XprintPrintStartJobCookie{cookie} -} - -func (c *Conn) XprintPrintStartJobChecked(OutputMode byte) XprintPrintStartJobCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintStartJobRequest(OutputMode), cookie) - return XprintPrintStartJobCookie{cookie} -} - -func (cook XprintPrintStartJobCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintStartJob -func (c *Conn) xprintPrintStartJobRequest(OutputMode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = OutputMode - b += 1 - - return buf -} - -// Request XprintPrintEndJob -// size: 8 -type XprintPrintEndJobCookie struct { - *cookie -} - -// Write request to wire for XprintPrintEndJob -func (c *Conn) XprintPrintEndJob(Cancel bool) XprintPrintEndJobCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintEndJobRequest(Cancel), cookie) - return XprintPrintEndJobCookie{cookie} -} - -func (c *Conn) XprintPrintEndJobChecked(Cancel bool) XprintPrintEndJobCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintEndJobRequest(Cancel), cookie) - return XprintPrintEndJobCookie{cookie} -} - -func (cook XprintPrintEndJobCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintEndJob -func (c *Conn) xprintPrintEndJobRequest(Cancel bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request XprintPrintStartDoc -// size: 8 -type XprintPrintStartDocCookie struct { - *cookie -} - -// Write request to wire for XprintPrintStartDoc -func (c *Conn) XprintPrintStartDoc(DriverMode byte) XprintPrintStartDocCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintStartDocRequest(DriverMode), cookie) - return XprintPrintStartDocCookie{cookie} -} - -func (c *Conn) XprintPrintStartDocChecked(DriverMode byte) XprintPrintStartDocCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintStartDocRequest(DriverMode), cookie) - return XprintPrintStartDocCookie{cookie} -} - -func (cook XprintPrintStartDocCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintStartDoc -func (c *Conn) xprintPrintStartDocRequest(DriverMode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DriverMode - b += 1 - - return buf -} - -// Request XprintPrintEndDoc -// size: 8 -type XprintPrintEndDocCookie struct { - *cookie -} - -// Write request to wire for XprintPrintEndDoc -func (c *Conn) XprintPrintEndDoc(Cancel bool) XprintPrintEndDocCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintEndDocRequest(Cancel), cookie) - return XprintPrintEndDocCookie{cookie} -} - -func (c *Conn) XprintPrintEndDocChecked(Cancel bool) XprintPrintEndDocCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintEndDocRequest(Cancel), cookie) - return XprintPrintEndDocCookie{cookie} -} - -func (cook XprintPrintEndDocCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintEndDoc -func (c *Conn) xprintPrintEndDocRequest(Cancel bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request XprintPrintPutDocumentData -// size: pad((((16 + pad((int(LenData) * 1))) + pad((len(DocFormat) * 1))) + pad((len(Options) * 1)))) -type XprintPrintPutDocumentDataCookie struct { - *cookie -} - -// Write request to wire for XprintPrintPutDocumentData -func (c *Conn) XprintPrintPutDocumentData(Drawable Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []XprintString8, Options []XprintString8) XprintPrintPutDocumentDataCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintPutDocumentDataRequest(Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return XprintPrintPutDocumentDataCookie{cookie} -} - -func (c *Conn) XprintPrintPutDocumentDataChecked(Drawable Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []XprintString8, Options []XprintString8) XprintPrintPutDocumentDataCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintPutDocumentDataRequest(Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return XprintPrintPutDocumentDataCookie{cookie} -} - -func (cook XprintPrintPutDocumentDataCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintPutDocumentData -func (c *Conn) xprintPrintPutDocumentDataRequest(Drawable Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []XprintString8, Options []XprintString8) []byte { - size := pad((((16 + pad((int(LenData) * 1))) + pad((len(DocFormat) * 1))) + pad((len(Options) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 11 // 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:], LenData) - b += 4 - - Put16(buf[b:], LenFmt) - b += 2 - - Put16(buf[b:], LenOptions) - b += 2 - - copy(buf[b:], Data[:LenData]) - b += pad(int(LenData)) - - for i := 0; i < int(len(DocFormat)); i++ { - buf[b] = byte(DocFormat[i]) - b += 1 - } - b = pad(b) - - for i := 0; i < int(len(Options)); i++ { - buf[b] = byte(Options[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintGetDocumentData -// size: 12 -type XprintPrintGetDocumentDataCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetDocumentData(Context XprintPcontext, MaxBytes uint32) XprintPrintGetDocumentDataCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetDocumentDataRequest(Context, MaxBytes), cookie) - return XprintPrintGetDocumentDataCookie{cookie} -} - -func (c *Conn) XprintPrintGetDocumentDataUnchecked(Context XprintPcontext, MaxBytes uint32) XprintPrintGetDocumentDataCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetDocumentDataRequest(Context, MaxBytes), cookie) - return XprintPrintGetDocumentDataCookie{cookie} -} - -// Request reply for XprintPrintGetDocumentData -// size: (32 + pad((int(DataLen) * 1))) -type XprintPrintGetDocumentDataReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - StatusCode uint32 - FinishedFlag uint32 - DataLen uint32 - // padding: 12 bytes - Data []byte // size: pad((int(DataLen) * 1)) -} - -// Waits and reads reply data from request XprintPrintGetDocumentData -func (cook XprintPrintGetDocumentDataCookie) Reply() (*XprintPrintGetDocumentDataReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetDocumentDataReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetDocumentData -func xprintPrintGetDocumentDataReply(buf []byte) *XprintPrintGetDocumentDataReply { - v := new(XprintPrintGetDocumentDataReply) - 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.StatusCode = Get32(buf[b:]) - b += 4 - - v.FinishedFlag = Get32(buf[b:]) - b += 4 - - v.DataLen = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, v.DataLen) - copy(v.Data[:v.DataLen], buf[b:]) - b += pad(int(v.DataLen)) - - return v -} - -func (cook XprintPrintGetDocumentDataCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetDocumentData -func (c *Conn) xprintPrintGetDocumentDataRequest(Context XprintPcontext, MaxBytes uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], MaxBytes) - b += 4 - - return buf -} - -// Request XprintPrintStartPage -// size: 8 -type XprintPrintStartPageCookie struct { - *cookie -} - -// Write request to wire for XprintPrintStartPage -func (c *Conn) XprintPrintStartPage(Window Window) XprintPrintStartPageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintStartPageRequest(Window), cookie) - return XprintPrintStartPageCookie{cookie} -} - -func (c *Conn) XprintPrintStartPageChecked(Window Window) XprintPrintStartPageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintStartPageRequest(Window), cookie) - return XprintPrintStartPageCookie{cookie} -} - -func (cook XprintPrintStartPageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintStartPage -func (c *Conn) xprintPrintStartPageRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 13 // 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 XprintPrintEndPage -// size: 8 -type XprintPrintEndPageCookie struct { - *cookie -} - -// Write request to wire for XprintPrintEndPage -func (c *Conn) XprintPrintEndPage(Cancel bool) XprintPrintEndPageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintEndPageRequest(Cancel), cookie) - return XprintPrintEndPageCookie{cookie} -} - -func (c *Conn) XprintPrintEndPageChecked(Cancel bool) XprintPrintEndPageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintEndPageRequest(Cancel), cookie) - return XprintPrintEndPageCookie{cookie} -} - -func (cook XprintPrintEndPageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintEndPage -func (c *Conn) xprintPrintEndPageRequest(Cancel bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XprintPrintSelectInput -// size: pad((8 + (4 + pad((4 * popCount(int(EventMask))))))) -type XprintPrintSelectInputCookie struct { - *cookie -} - -// Write request to wire for XprintPrintSelectInput -func (c *Conn) XprintPrintSelectInput(Context XprintPcontext, EventMask uint32, EventList []uint32) XprintPrintSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintSelectInputRequest(Context, EventMask, EventList), cookie) - return XprintPrintSelectInputCookie{cookie} -} - -func (c *Conn) XprintPrintSelectInputChecked(Context XprintPcontext, EventMask uint32, EventList []uint32) XprintPrintSelectInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintSelectInputRequest(Context, EventMask, EventList), cookie) - return XprintPrintSelectInputCookie{cookie} -} - -func (cook XprintPrintSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSelectInput -func (c *Conn) xprintPrintSelectInputRequest(Context XprintPcontext, EventMask uint32, EventList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(EventMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - for i := 0; i < popCount(int(EventMask)); i++ { - Put32(buf[b:], EventList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XprintPrintInputSelected -// size: 8 -type XprintPrintInputSelectedCookie struct { - *cookie -} - -func (c *Conn) XprintPrintInputSelected(Context XprintPcontext) XprintPrintInputSelectedCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintInputSelectedRequest(Context), cookie) - return XprintPrintInputSelectedCookie{cookie} -} - -func (c *Conn) XprintPrintInputSelectedUnchecked(Context XprintPcontext) XprintPrintInputSelectedCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintInputSelectedRequest(Context), cookie) - return XprintPrintInputSelectedCookie{cookie} -} - -// Request reply for XprintPrintInputSelected -// size: ((8 + (4 + pad((4 * popCount(int(EventMask)))))) + (4 + pad((4 * popCount(int(AllEventsMask)))))) -type XprintPrintInputSelectedReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - EventMask uint32 - EventList []uint32 - AllEventsMask uint32 - AllEventsList []uint32 -} - -// Waits and reads reply data from request XprintPrintInputSelected -func (cook XprintPrintInputSelectedCookie) Reply() (*XprintPrintInputSelectedReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintInputSelectedReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintInputSelected -func xprintPrintInputSelectedReply(buf []byte) *XprintPrintInputSelectedReply { - v := new(XprintPrintInputSelectedReply) - 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.EventMask = Get32(buf[b:]) - b += 4 - - v.EventList = make([]uint32, popCount(int(v.EventMask))) - for i := 0; i < popCount(int(v.EventMask)); i++ { - v.EventList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.AllEventsMask = Get32(buf[b:]) - b += 4 - - v.AllEventsList = make([]uint32, popCount(int(v.AllEventsMask))) - for i := 0; i < popCount(int(v.AllEventsMask)); i++ { - v.AllEventsList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XprintPrintInputSelectedCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintInputSelected -func (c *Conn) xprintPrintInputSelectedRequest(Context XprintPcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request XprintPrintGetAttributes -// size: 12 -type XprintPrintGetAttributesCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetAttributes(Context XprintPcontext, Pool byte) XprintPrintGetAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetAttributesRequest(Context, Pool), cookie) - return XprintPrintGetAttributesCookie{cookie} -} - -func (c *Conn) XprintPrintGetAttributesUnchecked(Context XprintPcontext, Pool byte) XprintPrintGetAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetAttributesRequest(Context, Pool), cookie) - return XprintPrintGetAttributesCookie{cookie} -} - -// Request reply for XprintPrintGetAttributes -// size: 33 -type XprintPrintGetAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - StringLen uint32 - // padding: 20 bytes - Attributes XprintString8 -} - -// Waits and reads reply data from request XprintPrintGetAttributes -func (cook XprintPrintGetAttributesCookie) Reply() (*XprintPrintGetAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetAttributes -func xprintPrintGetAttributesReply(buf []byte) *XprintPrintGetAttributesReply { - v := new(XprintPrintGetAttributesReply) - 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.StringLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attributes = XprintString8(buf[b]) - b += 1 - - return v -} - -func (cook XprintPrintGetAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetAttributes -func (c *Conn) xprintPrintGetAttributesRequest(Context XprintPcontext, Pool byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - - return buf -} - -// Request XprintPrintGetOneAttributes -// size: pad((16 + pad((int(NameLen) * 1)))) -type XprintPrintGetOneAttributesCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetOneAttributes(Context XprintPcontext, NameLen uint32, Pool byte, Name []XprintString8) XprintPrintGetOneAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetOneAttributesRequest(Context, NameLen, Pool, Name), cookie) - return XprintPrintGetOneAttributesCookie{cookie} -} - -func (c *Conn) XprintPrintGetOneAttributesUnchecked(Context XprintPcontext, NameLen uint32, Pool byte, Name []XprintString8) XprintPrintGetOneAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetOneAttributesRequest(Context, NameLen, Pool, Name), cookie) - return XprintPrintGetOneAttributesCookie{cookie} -} - -// Request reply for XprintPrintGetOneAttributes -// size: (32 + pad((int(ValueLen) * 1))) -type XprintPrintGetOneAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ValueLen uint32 - // padding: 20 bytes - Value []XprintString8 // size: pad((int(ValueLen) * 1)) -} - -// Waits and reads reply data from request XprintPrintGetOneAttributes -func (cook XprintPrintGetOneAttributesCookie) Reply() (*XprintPrintGetOneAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetOneAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetOneAttributes -func xprintPrintGetOneAttributesReply(buf []byte) *XprintPrintGetOneAttributesReply { - v := new(XprintPrintGetOneAttributesReply) - 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.ValueLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Value = make([]XprintString8, v.ValueLen) - for i := 0; i < int(v.ValueLen); i++ { - v.Value[i] = XprintString8(buf[b]) - b += 1 - } - b = pad(b) - - return v -} - -func (cook XprintPrintGetOneAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetOneAttributes -func (c *Conn) xprintPrintGetOneAttributesRequest(Context XprintPcontext, NameLen uint32, Pool byte, Name []XprintString8) []byte { - size := pad((16 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], NameLen) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - - for i := 0; i < int(NameLen); i++ { - buf[b] = byte(Name[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintSetAttributes -// size: pad((16 + pad((len(Attributes) * 1)))) -type XprintPrintSetAttributesCookie struct { - *cookie -} - -// Write request to wire for XprintPrintSetAttributes -func (c *Conn) XprintPrintSetAttributes(Context XprintPcontext, StringLen uint32, Pool byte, Rule byte, Attributes []XprintString8) XprintPrintSetAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintSetAttributesRequest(Context, StringLen, Pool, Rule, Attributes), cookie) - return XprintPrintSetAttributesCookie{cookie} -} - -func (c *Conn) XprintPrintSetAttributesChecked(Context XprintPcontext, StringLen uint32, Pool byte, Rule byte, Attributes []XprintString8) XprintPrintSetAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintSetAttributesRequest(Context, StringLen, Pool, Rule, Attributes), cookie) - return XprintPrintSetAttributesCookie{cookie} -} - -func (cook XprintPrintSetAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSetAttributes -func (c *Conn) xprintPrintSetAttributesRequest(Context XprintPcontext, StringLen uint32, Pool byte, Rule byte, Attributes []XprintString8) []byte { - size := pad((16 + pad((len(Attributes) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], StringLen) - b += 4 - - buf[b] = Pool - b += 1 - - buf[b] = Rule - b += 1 - - b += 2 // padding - - for i := 0; i < int(len(Attributes)); i++ { - buf[b] = byte(Attributes[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintGetPageDimensions -// size: 8 -type XprintPrintGetPageDimensionsCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetPageDimensions(Context XprintPcontext) XprintPrintGetPageDimensionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetPageDimensionsRequest(Context), cookie) - return XprintPrintGetPageDimensionsCookie{cookie} -} - -func (c *Conn) XprintPrintGetPageDimensionsUnchecked(Context XprintPcontext) XprintPrintGetPageDimensionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetPageDimensionsRequest(Context), cookie) - return XprintPrintGetPageDimensionsCookie{cookie} -} - -// Request reply for XprintPrintGetPageDimensions -// size: 20 -type XprintPrintGetPageDimensionsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint16 - Height uint16 - OffsetX uint16 - OffsetY uint16 - ReproducibleWidth uint16 - ReproducibleHeight uint16 -} - -// Waits and reads reply data from request XprintPrintGetPageDimensions -func (cook XprintPrintGetPageDimensionsCookie) Reply() (*XprintPrintGetPageDimensionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetPageDimensionsReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetPageDimensions -func xprintPrintGetPageDimensionsReply(buf []byte) *XprintPrintGetPageDimensionsReply { - v := new(XprintPrintGetPageDimensionsReply) - 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 = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.OffsetX = Get16(buf[b:]) - b += 2 - - v.OffsetY = Get16(buf[b:]) - b += 2 - - v.ReproducibleWidth = Get16(buf[b:]) - b += 2 - - v.ReproducibleHeight = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintGetPageDimensionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetPageDimensions -func (c *Conn) xprintPrintGetPageDimensionsRequest(Context XprintPcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request XprintPrintQueryScreens -// size: 4 -type XprintPrintQueryScreensCookie struct { - *cookie -} - -func (c *Conn) XprintPrintQueryScreens() XprintPrintQueryScreensCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintQueryScreensRequest(), cookie) - return XprintPrintQueryScreensCookie{cookie} -} - -func (c *Conn) XprintPrintQueryScreensUnchecked() XprintPrintQueryScreensCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintQueryScreensRequest(), cookie) - return XprintPrintQueryScreensCookie{cookie} -} - -// Request reply for XprintPrintQueryScreens -// size: (32 + pad((int(ListCount) * 4))) -type XprintPrintQueryScreensReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Roots []Window // size: pad((int(ListCount) * 4)) -} - -// Waits and reads reply data from request XprintPrintQueryScreens -func (cook XprintPrintQueryScreensCookie) Reply() (*XprintPrintQueryScreensReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintQueryScreensReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintQueryScreens -func xprintPrintQueryScreensReply(buf []byte) *XprintPrintQueryScreensReply { - v := new(XprintPrintQueryScreensReply) - 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.ListCount = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Roots = make([]Window, v.ListCount) - for i := 0; i < int(v.ListCount); i++ { - v.Roots[i] = Window(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XprintPrintQueryScreensCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintQueryScreens -func (c *Conn) xprintPrintQueryScreensRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintPrintSetImageResolution -// size: 12 -type XprintPrintSetImageResolutionCookie struct { - *cookie -} - -func (c *Conn) XprintPrintSetImageResolution(Context XprintPcontext, ImageResolution uint16) XprintPrintSetImageResolutionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintSetImageResolutionRequest(Context, ImageResolution), cookie) - return XprintPrintSetImageResolutionCookie{cookie} -} - -func (c *Conn) XprintPrintSetImageResolutionUnchecked(Context XprintPcontext, ImageResolution uint16) XprintPrintSetImageResolutionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintSetImageResolutionRequest(Context, ImageResolution), cookie) - return XprintPrintSetImageResolutionCookie{cookie} -} - -// Request reply for XprintPrintSetImageResolution -// size: 10 -type XprintPrintSetImageResolutionReply struct { - Sequence uint16 - Length uint32 - Status bool - PreviousResolutions uint16 -} - -// Waits and reads reply data from request XprintPrintSetImageResolution -func (cook XprintPrintSetImageResolutionCookie) Reply() (*XprintPrintSetImageResolutionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintSetImageResolutionReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintSetImageResolution -func xprintPrintSetImageResolutionReply(buf []byte) *XprintPrintSetImageResolutionReply { - v := new(XprintPrintSetImageResolutionReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.Status = true - } else { - v.Status = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PreviousResolutions = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintSetImageResolutionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSetImageResolution -func (c *Conn) xprintPrintSetImageResolutionRequest(Context XprintPcontext, ImageResolution uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put16(buf[b:], ImageResolution) - b += 2 - - return buf -} - -// Request XprintPrintGetImageResolution -// size: 8 -type XprintPrintGetImageResolutionCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetImageResolution(Context XprintPcontext) XprintPrintGetImageResolutionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetImageResolutionRequest(Context), cookie) - return XprintPrintGetImageResolutionCookie{cookie} -} - -func (c *Conn) XprintPrintGetImageResolutionUnchecked(Context XprintPcontext) XprintPrintGetImageResolutionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetImageResolutionRequest(Context), cookie) - return XprintPrintGetImageResolutionCookie{cookie} -} - -// Request reply for XprintPrintGetImageResolution -// size: 10 -type XprintPrintGetImageResolutionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ImageResolution uint16 -} - -// Waits and reads reply data from request XprintPrintGetImageResolution -func (cook XprintPrintGetImageResolutionCookie) Reply() (*XprintPrintGetImageResolutionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetImageResolutionReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetImageResolution -func xprintPrintGetImageResolutionReply(buf []byte) *XprintPrintGetImageResolutionReply { - v := new(XprintPrintGetImageResolutionReply) - 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.ImageResolution = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintGetImageResolutionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetImageResolution -func (c *Conn) xprintPrintGetImageResolutionRequest(Context XprintPcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} diff --git a/nexgb/auto_xproto.go b/nexgb/auto_xproto.go deleted file mode 100644 index 8bd39b3..0000000 --- a/nexgb/auto_xproto.go +++ /dev/null @@ -1,14490 +0,0 @@ -package xgb - -/* - This file was generated by xproto.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// 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 ( - VisualClassStaticGray = 0 - VisualClassGrayScale = 1 - VisualClassStaticColor = 2 - VisualClassPseudoColor = 3 - VisualClassTrueColor = 4 - VisualClassDirectColor = 5 -) - -const ( - EventMaskNoEvent = 0 - EventMaskKeyPress = 1 - EventMaskKeyRelease = 2 - EventMaskButtonPress = 4 - EventMaskButtonRelease = 8 - EventMaskEnterWindow = 16 - EventMaskLeaveWindow = 32 - EventMaskPointerMotion = 64 - EventMaskPointerMotionHint = 128 - EventMaskButton1Motion = 256 - EventMaskButton2Motion = 512 - EventMaskButton3Motion = 1024 - EventMaskButton4Motion = 2048 - EventMaskButton5Motion = 4096 - EventMaskButtonMotion = 8192 - EventMaskKeymapState = 16384 - EventMaskExposure = 32768 - EventMaskVisibilityChange = 65536 - EventMaskStructureNotify = 131072 - EventMaskResizeRedirect = 262144 - EventMaskSubstructureNotify = 524288 - EventMaskSubstructureRedirect = 1048576 - EventMaskFocusChange = 2097152 - EventMaskPropertyChange = 4194304 - EventMaskColorMapChange = 8388608 - EventMaskOwnerGrabButton = 16777216 -) - -const ( - BackingStoreNotUseful = 0 - BackingStoreWhenMapped = 1 - BackingStoreAlways = 2 -) - -const ( - ImageOrderLSBFirst = 0 - ImageOrderMSBFirst = 1 -) - -const ( - ModMaskShift = 1 - ModMaskLock = 2 - ModMaskControl = 4 - ModMask1 = 8 - ModMask2 = 16 - ModMask3 = 32 - ModMask4 = 64 - ModMask5 = 128 - ModMaskAny = 32768 -) - -const ( - KeyButMaskShift = 1 - KeyButMaskLock = 2 - KeyButMaskControl = 4 - KeyButMaskMod1 = 8 - KeyButMaskMod2 = 16 - KeyButMaskMod3 = 32 - KeyButMaskMod4 = 64 - KeyButMaskMod5 = 128 - KeyButMaskButton1 = 256 - KeyButMaskButton2 = 512 - KeyButMaskButton3 = 1024 - KeyButMaskButton4 = 2048 - KeyButMaskButton5 = 4096 -) - -const ( - WindowNone = 0 -) - -const ( - ButtonMask1 = 256 - ButtonMask2 = 512 - ButtonMask3 = 1024 - ButtonMask4 = 2048 - ButtonMask5 = 4096 - ButtonMaskAny = 32768 -) - -const ( - MotionNormal = 0 - MotionHint = 1 -) - -const ( - NotifyDetailAncestor = 0 - NotifyDetailVirtual = 1 - NotifyDetailInferior = 2 - NotifyDetailNonlinear = 3 - NotifyDetailNonlinearVirtual = 4 - NotifyDetailPointer = 5 - NotifyDetailPointerRoot = 6 - NotifyDetailNone = 7 -) - -const ( - NotifyModeNormal = 0 - NotifyModeGrab = 1 - NotifyModeUngrab = 2 - NotifyModeWhileGrabbed = 3 -) - -const ( - VisibilityUnobscured = 0 - VisibilityPartiallyObscured = 1 - VisibilityFullyObscured = 2 -) - -const ( - PlaceOnTop = 0 - PlaceOnBottom = 1 -) - -const ( - PropertyNewValue = 0 - PropertyDelete = 1 -) - -const ( - TimeCurrentTime = 0 -) - -const ( - AtomNone = 0 - AtomAny = 0 - AtomPrimary = 1 - AtomSecondary = 2 - AtomArc = 3 - AtomAtom = 4 - AtomBitmap = 5 - AtomCardinal = 6 - AtomColormap = 7 - AtomCursor = 8 - AtomCutBuffer0 = 9 - AtomCutBuffer1 = 10 - AtomCutBuffer2 = 11 - AtomCutBuffer3 = 12 - AtomCutBuffer4 = 13 - AtomCutBuffer5 = 14 - AtomCutBuffer6 = 15 - AtomCutBuffer7 = 16 - AtomDrawable = 17 - AtomFont = 18 - AtomInteger = 19 - AtomPixmap = 20 - AtomPoint = 21 - AtomRectangle = 22 - AtomResourceManager = 23 - AtomRgbColorMap = 24 - AtomRgbBestMap = 25 - AtomRgbBlueMap = 26 - AtomRgbDefaultMap = 27 - AtomRgbGrayMap = 28 - AtomRgbGreenMap = 29 - AtomRgbRedMap = 30 - AtomString = 31 - AtomVisualid = 32 - AtomWindow = 33 - AtomWmCommand = 34 - AtomWmHints = 35 - AtomWmClientMachine = 36 - AtomWmIconName = 37 - AtomWmIconSize = 38 - AtomWmName = 39 - AtomWmNormalHints = 40 - AtomWmSizeHints = 41 - AtomWmZoomHints = 42 - AtomMinSpace = 43 - AtomNormSpace = 44 - AtomMaxSpace = 45 - AtomEndSpace = 46 - AtomSuperscriptX = 47 - AtomSuperscriptY = 48 - AtomSubscriptX = 49 - AtomSubscriptY = 50 - AtomUnderlinePosition = 51 - AtomUnderlineThickness = 52 - AtomStrikeoutAscent = 53 - AtomStrikeoutDescent = 54 - AtomItalicAngle = 55 - AtomXHeight = 56 - AtomQuadWidth = 57 - AtomWeight = 58 - AtomPointSize = 59 - AtomResolution = 60 - AtomCopyright = 61 - AtomNotice = 62 - AtomFontName = 63 - AtomFamilyName = 64 - AtomFullName = 65 - AtomCapHeight = 66 - AtomWmClass = 67 - AtomWmTransientFor = 68 -) - -const ( - ColormapStateUninstalled = 0 - ColormapStateInstalled = 1 -) - -const ( - ColormapNone = 0 -) - -const ( - MappingModifier = 0 - MappingKeyboard = 1 - MappingPointer = 2 -) - -const ( - WindowClassCopyFromParent = 0 - WindowClassInputOutput = 1 - WindowClassInputOnly = 2 -) - -const ( - CwBackPixmap = 1 - CwBackPixel = 2 - CwBorderPixmap = 4 - CwBorderPixel = 8 - CwBitGravity = 16 - CwWinGravity = 32 - CwBackingStore = 64 - CwBackingPlanes = 128 - CwBackingPixel = 256 - CwOverrideRedirect = 512 - CwSaveUnder = 1024 - CwEventMask = 2048 - CwDontPropagate = 4096 - CwColormap = 8192 - CwCursor = 16384 -) - -const ( - BackPixmapNone = 0 - BackPixmapParentRelative = 1 -) - -const ( - GravityBitForget = 0 - GravityWinUnmap = 0 - GravityNorthWest = 1 - GravityNorth = 2 - GravityNorthEast = 3 - GravityWest = 4 - GravityCenter = 5 - GravityEast = 6 - GravitySouthWest = 7 - GravitySouth = 8 - GravitySouthEast = 9 - GravityStatic = 10 -) - -const ( - MapStateUnmapped = 0 - MapStateUnviewable = 1 - MapStateViewable = 2 -) - -const ( - SetModeInsert = 0 - SetModeDelete = 1 -) - -const ( - ConfigWindowX = 1 - ConfigWindowY = 2 - ConfigWindowWidth = 4 - ConfigWindowHeight = 8 - ConfigWindowBorderWidth = 16 - ConfigWindowSibling = 32 - ConfigWindowStackMode = 64 -) - -const ( - StackModeAbove = 0 - StackModeBelow = 1 - StackModeTopIf = 2 - StackModeBottomIf = 3 - StackModeOpposite = 4 -) - -const ( - CirculateRaiseLowest = 0 - CirculateLowerHighest = 1 -) - -const ( - PropModeReplace = 0 - PropModePrepend = 1 - PropModeAppend = 2 -) - -const ( - GetPropertyTypeAny = 0 -) - -const ( - SendEventDestPointerWindow = 0 - SendEventDestItemFocus = 1 -) - -const ( - GrabModeSync = 0 - GrabModeAsync = 1 -) - -const ( - GrabStatusSuccess = 0 - GrabStatusAlreadyGrabbed = 1 - GrabStatusInvalidTime = 2 - GrabStatusNotViewable = 3 - GrabStatusFrozen = 4 -) - -const ( - CursorNone = 0 -) - -const ( - ButtonIndexAny = 0 - ButtonIndex1 = 1 - ButtonIndex2 = 2 - ButtonIndex3 = 3 - ButtonIndex4 = 4 - ButtonIndex5 = 5 -) - -const ( - GrabAny = 0 -) - -const ( - AllowAsyncPointer = 0 - AllowSyncPointer = 1 - AllowReplayPointer = 2 - AllowAsyncKeyboard = 3 - AllowSyncKeyboard = 4 - AllowReplayKeyboard = 5 - AllowAsyncBoth = 6 - AllowSyncBoth = 7 -) - -const ( - InputFocusNone = 0 - InputFocusPointerRoot = 1 - InputFocusParent = 2 - InputFocusFollowKeyboard = 3 -) - -const ( - FontDrawLeftToRight = 0 - FontDrawRightToLeft = 1 -) - -const ( - GcFunction = 1 - GcPlaneMask = 2 - GcForeground = 4 - GcBackground = 8 - GcLineWidth = 16 - GcLineStyle = 32 - GcCapStyle = 64 - GcJoinStyle = 128 - GcFillStyle = 256 - GcFillRule = 512 - GcTile = 1024 - GcStipple = 2048 - GcTileStippleOriginX = 4096 - GcTileStippleOriginY = 8192 - GcFont = 16384 - GcSubwindowMode = 32768 - GcGraphicsExposures = 65536 - GcClipOriginX = 131072 - GcClipOriginY = 262144 - GcClipMask = 524288 - GcDashOffset = 1048576 - GcDashList = 2097152 - GcArcMode = 4194304 -) - -const ( - GxClear = 0 - GxAnd = 1 - GxAndReverse = 2 - GxCopy = 3 - GxAndInverted = 4 - GxNoop = 5 - GxXor = 6 - GxOr = 7 - GxNor = 8 - GxEquiv = 9 - GxInvert = 10 - GxOrReverse = 11 - GxCopyInverted = 12 - GxOrInverted = 13 - GxNand = 14 - GxSet = 15 -) - -const ( - LineStyleSolid = 0 - LineStyleOnOffDash = 1 - LineStyleDoubleDash = 2 -) - -const ( - CapStyleNotLast = 0 - CapStyleButt = 1 - CapStyleRound = 2 - CapStyleProjecting = 3 -) - -const ( - JoinStyleMiter = 0 - JoinStyleRound = 1 - JoinStyleBevel = 2 -) - -const ( - FillStyleSolid = 0 - FillStyleTiled = 1 - FillStyleStippled = 2 - FillStyleOpaqueStippled = 3 -) - -const ( - FillRuleEvenOdd = 0 - FillRuleWinding = 1 -) - -const ( - SubwindowModeClipByChildren = 0 - SubwindowModeIncludeInferiors = 1 -) - -const ( - ArcModeChord = 0 - ArcModePieSlice = 1 -) - -const ( - ClipOrderingUnsorted = 0 - ClipOrderingYSorted = 1 - ClipOrderingYXSorted = 2 - ClipOrderingYXBanded = 3 -) - -const ( - CoordModeOrigin = 0 - CoordModePrevious = 1 -) - -const ( - PolyShapeComplex = 0 - PolyShapeNonconvex = 1 - PolyShapeConvex = 2 -) - -const ( - ImageFormatXYBitmap = 0 - ImageFormatXYPixmap = 1 - ImageFormatZPixmap = 2 -) - -const ( - ColormapAllocNone = 0 - ColormapAllocAll = 1 -) - -const ( - ColorFlagRed = 1 - ColorFlagGreen = 2 - ColorFlagBlue = 4 -) - -const ( - PixmapNone = 0 -) - -const ( - FontNone = 0 -) - -const ( - QueryShapeOfLargestCursor = 0 - QueryShapeOfFastestTile = 1 - QueryShapeOfFastestStipple = 2 -) - -const ( - KbKeyClickPercent = 1 - KbBellPercent = 2 - KbBellPitch = 4 - KbBellDuration = 8 - KbLed = 16 - KbLedMode = 32 - KbKey = 64 - KbAutoRepeatMode = 128 -) - -const ( - LedModeOff = 0 - LedModeOn = 1 -) - -const ( - AutoRepeatModeOff = 0 - AutoRepeatModeOn = 1 - AutoRepeatModeDefault = 2 -) - -const ( - BlankingNotPreferred = 0 - BlankingPreferred = 1 - BlankingDefault = 2 -) - -const ( - ExposuresNotAllowed = 0 - ExposuresAllowed = 1 - ExposuresDefault = 2 -) - -const ( - HostModeInsert = 0 - HostModeDelete = 1 -) - -const ( - FamilyInternet = 0 - FamilyDECnet = 1 - FamilyChaos = 2 - FamilyServerInterpreted = 5 - FamilyInternet6 = 6 -) - -const ( - AccessControlDisable = 0 - AccessControlEnable = 1 -) - -const ( - CloseDownDestroyAll = 0 - CloseDownRetainPermanent = 1 - CloseDownRetainTemporary = 2 -) - -const ( - KillAllTemporary = 0 -) - -const ( - ScreenSaverReset = 0 - ScreenSaverActive = 1 -) - -const ( - MappingStatusSuccess = 0 - MappingStatusBusy = 1 - MappingStatusFailure = 2 -) - -const ( - MapIndexShift = 0 - MapIndexLock = 1 - MapIndexControl = 2 - MapIndex1 = 3 - MapIndex2 = 4 - MapIndex3 = 5 - MapIndex4 = 6 - MapIndex5 = 7 -) - -type Window uint32 - -func (c *Conn) NewWindowId() (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} - -type Pixmap uint32 - -func (c *Conn) NewPixmapId() (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} - -type Cursor uint32 - -func (c *Conn) NewCursorId() (Cursor, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Cursor(id), nil -} - -type Font uint32 - -func (c *Conn) NewFontId() (Font, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Font(id), nil -} - -type Gcontext uint32 - -func (c *Conn) NewGcontextId() (Gcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Gcontext(id), nil -} - -type Colormap uint32 - -func (c *Conn) NewColormapId() (Colormap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Colormap(id), nil -} - -type Atom uint32 - -func (c *Conn) NewAtomId() (Atom, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Atom(id), nil -} - -type Drawable uint32 - -func (c *Conn) NewDrawableId() (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil -} - -type Fontable uint32 - -func (c *Conn) NewFontableId() (Fontable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fontable(id), nil -} - -type Visualid uint32 - -type Timestamp uint32 - -type Keysym uint32 - -type Keycode byte - -type Button byte - -// 'Char2b' struct definition -// Size: 2 -type Char2b struct { - Byte1 byte - Byte2 byte -} - -// Struct read Char2b -func ReadChar2b(buf []byte, v *Char2b) int { - b := 0 - - v.Byte1 = buf[b] - b += 1 - - v.Byte2 = buf[b] - b += 1 - - return b -} - -// Struct list read Char2b -func ReadChar2bList(buf []byte, dest []Char2b) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Char2b{} - b += ReadChar2b(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Char2b -func (v Char2b) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.Byte1 - b += 1 - - buf[b] = v.Byte2 - b += 1 - - return buf -} - -// Write struct list Char2b -func Char2bListBytes(buf []byte, list []Char2b) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Point' struct definition -// Size: 4 -type Point struct { - X int16 - Y int16 -} - -// Struct read Point -func ReadPoint(buf []byte, v *Point) int { - b := 0 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Point -func ReadPointList(buf []byte, dest []Point) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Point{} - b += ReadPoint(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Point -func (v Point) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// Write struct list Point -func PointListBytes(buf []byte, list []Point) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Rectangle' struct definition -// Size: 8 -type Rectangle struct { - X int16 - Y int16 - Width uint16 - Height uint16 -} - -// Struct read Rectangle -func ReadRectangle(buf []byte, v *Rectangle) int { - b := 0 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = 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 Rectangle -func ReadRectangleList(buf []byte, dest []Rectangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rectangle{} - b += ReadRectangle(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Rectangle -func (v Rectangle) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// Write struct list Rectangle -func RectangleListBytes(buf []byte, list []Rectangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Arc' struct definition -// Size: 12 -type Arc struct { - X int16 - Y int16 - Width uint16 - Height uint16 - Angle1 int16 - Angle2 int16 -} - -// Struct read Arc -func ReadArc(buf []byte, v *Arc) int { - b := 0 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Angle1 = int16(Get16(buf[b:])) - b += 2 - - v.Angle2 = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Arc -func ReadArcList(buf []byte, dest []Arc) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Arc{} - b += ReadArc(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Arc -func (v Arc) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], uint16(v.Angle1)) - b += 2 - - Put16(buf[b:], uint16(v.Angle2)) - b += 2 - - return buf -} - -// Write struct list Arc -func ArcListBytes(buf []byte, list []Arc) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Format' struct definition -// Size: 8 -type Format struct { - Depth byte - BitsPerPixel byte - ScanlinePad byte - // padding: 5 bytes -} - -// Struct read Format -func ReadFormat(buf []byte, v *Format) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - v.BitsPerPixel = buf[b] - b += 1 - - v.ScanlinePad = buf[b] - b += 1 - - b += 5 // padding - - return b -} - -// Struct list read Format -func ReadFormatList(buf []byte, dest []Format) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += ReadFormat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Format -func (v Format) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.Depth - b += 1 - - buf[b] = v.BitsPerPixel - b += 1 - - buf[b] = v.ScanlinePad - b += 1 - - b += 5 // padding - - return buf -} - -// Write struct list Format -func FormatListBytes(buf []byte, list []Format) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'VisualInfo' struct definition -// Size: 24 -type VisualInfo struct { - VisualId Visualid - Class byte - BitsPerRgbValue byte - ColormapEntries uint16 - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 4 bytes -} - -// Struct read VisualInfo -func ReadVisualInfo(buf []byte, v *VisualInfo) int { - b := 0 - - v.VisualId = Visualid(Get32(buf[b:])) - b += 4 - - v.Class = buf[b] - b += 1 - - v.BitsPerRgbValue = buf[b] - b += 1 - - v.ColormapEntries = Get16(buf[b:]) - b += 2 - - v.RedMask = Get32(buf[b:]) - b += 4 - - v.GreenMask = Get32(buf[b:]) - b += 4 - - v.BlueMask = Get32(buf[b:]) - b += 4 - - b += 4 // padding - - return b -} - -// Struct list read VisualInfo -func ReadVisualInfoList(buf []byte, dest []VisualInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = VisualInfo{} - b += ReadVisualInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write VisualInfo -func (v VisualInfo) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - Put32(buf[b:], uint32(v.VisualId)) - b += 4 - - buf[b] = v.Class - b += 1 - - buf[b] = v.BitsPerRgbValue - b += 1 - - Put16(buf[b:], v.ColormapEntries) - b += 2 - - Put32(buf[b:], v.RedMask) - b += 4 - - Put32(buf[b:], v.GreenMask) - b += 4 - - Put32(buf[b:], v.BlueMask) - b += 4 - - b += 4 // padding - - return buf -} - -// Write struct list VisualInfo -func VisualInfoListBytes(buf []byte, list []VisualInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'DepthInfo' struct definition -// Size: (8 + pad((int(VisualsLen) * 24))) -type DepthInfo struct { - Depth byte - // padding: 1 bytes - VisualsLen uint16 - // padding: 4 bytes - Visuals []VisualInfo // size: pad((int(VisualsLen) * 24)) -} - -// Struct read DepthInfo -func ReadDepthInfo(buf []byte, v *DepthInfo) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - b += 1 // padding - - v.VisualsLen = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Visuals = make([]VisualInfo, v.VisualsLen) - b += ReadVisualInfoList(buf[b:], v.Visuals) - - return b -} - -// Struct list read DepthInfo -func ReadDepthInfoList(buf []byte, dest []DepthInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DepthInfo{} - b += ReadDepthInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write DepthInfo -func (v DepthInfo) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.VisualsLen) * 24)))) - b := 0 - - buf[b] = v.Depth - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.VisualsLen) - b += 2 - - b += 4 // padding - - b += VisualInfoListBytes(buf[b:], v.Visuals) - - return buf -} - -// Write struct list DepthInfo -func DepthInfoListBytes(buf []byte, list []DepthInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size DepthInfo -func DepthInfoListSize(list []DepthInfo) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.VisualsLen) * 24))) - } - return size -} - -// 'ScreenInfo' struct definition -// Size: (40 + DepthInfoListSize(AllowedDepths)) -type ScreenInfo struct { - Root Window - DefaultColormap Colormap - WhitePixel uint32 - BlackPixel uint32 - CurrentInputMasks uint32 - WidthInPixels uint16 - HeightInPixels uint16 - WidthInMillimeters uint16 - HeightInMillimeters uint16 - MinInstalledMaps uint16 - MaxInstalledMaps uint16 - RootVisual Visualid - BackingStores byte - SaveUnders bool - RootDepth byte - AllowedDepthsLen byte - AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) -} - -// Struct read ScreenInfo -func ReadScreenInfo(buf []byte, v *ScreenInfo) int { - b := 0 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.DefaultColormap = Colormap(Get32(buf[b:])) - b += 4 - - v.WhitePixel = Get32(buf[b:]) - b += 4 - - v.BlackPixel = Get32(buf[b:]) - b += 4 - - v.CurrentInputMasks = Get32(buf[b:]) - b += 4 - - v.WidthInPixels = Get16(buf[b:]) - b += 2 - - v.HeightInPixels = Get16(buf[b:]) - b += 2 - - v.WidthInMillimeters = Get16(buf[b:]) - b += 2 - - v.HeightInMillimeters = Get16(buf[b:]) - b += 2 - - v.MinInstalledMaps = Get16(buf[b:]) - b += 2 - - v.MaxInstalledMaps = Get16(buf[b:]) - b += 2 - - v.RootVisual = Visualid(Get32(buf[b:])) - b += 4 - - v.BackingStores = buf[b] - b += 1 - - if buf[b] == 1 { - v.SaveUnders = true - } else { - v.SaveUnders = false - } - b += 1 - - v.RootDepth = buf[b] - b += 1 - - v.AllowedDepthsLen = buf[b] - b += 1 - - v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) - b += ReadDepthInfoList(buf[b:], v.AllowedDepths) - - return b -} - -// Struct list read ScreenInfo -func ReadScreenInfoList(buf []byte, dest []ScreenInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenInfo{} - b += ReadScreenInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write ScreenInfo -func (v ScreenInfo) Bytes() []byte { - buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) - b := 0 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.DefaultColormap)) - b += 4 - - Put32(buf[b:], v.WhitePixel) - b += 4 - - Put32(buf[b:], v.BlackPixel) - b += 4 - - Put32(buf[b:], v.CurrentInputMasks) - b += 4 - - Put16(buf[b:], v.WidthInPixels) - b += 2 - - Put16(buf[b:], v.HeightInPixels) - b += 2 - - Put16(buf[b:], v.WidthInMillimeters) - b += 2 - - Put16(buf[b:], v.HeightInMillimeters) - b += 2 - - Put16(buf[b:], v.MinInstalledMaps) - b += 2 - - Put16(buf[b:], v.MaxInstalledMaps) - b += 2 - - Put32(buf[b:], uint32(v.RootVisual)) - b += 4 - - buf[b] = v.BackingStores - b += 1 - - if v.SaveUnders { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.RootDepth - b += 1 - - buf[b] = v.AllowedDepthsLen - b += 1 - - b += DepthInfoListBytes(buf[b:], v.AllowedDepths) - - 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 += pad(len(structBytes)) - } - return b -} - -// Struct list size ScreenInfo -func ScreenInfoListSize(list []ScreenInfo) int { - size := 0 - for _, item := range list { - size += (40 + DepthInfoListSize(item.AllowedDepths)) - } - return size -} - -// 'SetupRequest' struct definition -// Size: ((12 + pad((int(AuthorizationProtocolNameLen) * 1))) + pad((int(AuthorizationProtocolDataLen) * 1))) -type SetupRequest struct { - ByteOrder byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - AuthorizationProtocolNameLen uint16 - AuthorizationProtocolDataLen uint16 - // padding: 2 bytes - AuthorizationProtocolName string // size: pad((int(AuthorizationProtocolNameLen) * 1)) - AuthorizationProtocolData string // size: pad((int(AuthorizationProtocolDataLen) * 1)) -} - -// Struct read SetupRequest -func ReadSetupRequest(buf []byte, v *SetupRequest) int { - b := 0 - - v.ByteOrder = buf[b] - b += 1 - - b += 1 // padding - - v.ProtocolMajorVersion = Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = Get16(buf[b:]) - b += 2 - - v.AuthorizationProtocolNameLen = Get16(buf[b:]) - b += 2 - - v.AuthorizationProtocolDataLen = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - { - byteString := make([]byte, v.AuthorizationProtocolNameLen) - copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) - v.AuthorizationProtocolName = string(byteString) - b += pad(int(v.AuthorizationProtocolNameLen)) - } - - { - byteString := make([]byte, v.AuthorizationProtocolDataLen) - copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) - v.AuthorizationProtocolData = string(byteString) - b += pad(int(v.AuthorizationProtocolDataLen)) - } - - return b -} - -// Struct list read SetupRequest -func ReadSetupRequestList(buf []byte, dest []SetupRequest) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupRequest{} - b += ReadSetupRequest(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupRequest -func (v SetupRequest) Bytes() []byte { - buf := make([]byte, ((12 + pad((int(v.AuthorizationProtocolNameLen) * 1))) + pad((int(v.AuthorizationProtocolDataLen) * 1)))) - b := 0 - - buf[b] = v.ByteOrder - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - Put16(buf[b:], v.AuthorizationProtocolNameLen) - b += 2 - - Put16(buf[b:], v.AuthorizationProtocolDataLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) - b += pad(int(v.AuthorizationProtocolNameLen)) - - copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) - b += pad(int(v.AuthorizationProtocolDataLen)) - - return buf -} - -// Write struct list SetupRequest -func SetupRequestListBytes(buf []byte, list []SetupRequest) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupRequest -func SetupRequestListSize(list []SetupRequest) int { - size := 0 - for _, item := range list { - size += ((12 + pad((int(item.AuthorizationProtocolNameLen) * 1))) + pad((int(item.AuthorizationProtocolDataLen) * 1))) - } - return size -} - -// 'SetupFailed' struct definition -// Size: (8 + pad((int(ReasonLen) * 1))) -type SetupFailed struct { - Status byte - ReasonLen byte - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - Reason string // size: pad((int(ReasonLen) * 1)) -} - -// Struct read SetupFailed -func ReadSetupFailed(buf []byte, v *SetupFailed) int { - b := 0 - - v.Status = buf[b] - b += 1 - - v.ReasonLen = buf[b] - b += 1 - - v.ProtocolMajorVersion = Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = Get16(buf[b:]) - b += 2 - - v.Length = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.ReasonLen) - copy(byteString[:v.ReasonLen], buf[b:]) - v.Reason = string(byteString) - b += pad(int(v.ReasonLen)) - } - - return b -} - -// Struct list read SetupFailed -func ReadSetupFailedList(buf []byte, dest []SetupFailed) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupFailed{} - b += ReadSetupFailed(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupFailed -func (v SetupFailed) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.ReasonLen) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - buf[b] = v.ReasonLen - b += 1 - - Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:v.ReasonLen]) - b += pad(int(v.ReasonLen)) - - return buf -} - -// Write struct list SetupFailed -func SetupFailedListBytes(buf []byte, list []SetupFailed) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupFailed -func SetupFailedListSize(list []SetupFailed) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.ReasonLen) * 1))) - } - return size -} - -// 'SetupAuthenticate' struct definition -// Size: (8 + pad(((int(Length) * 4) * 1))) -type SetupAuthenticate struct { - Status byte - // padding: 5 bytes - Length uint16 - Reason string // size: pad(((int(Length) * 4) * 1)) -} - -// Struct read SetupAuthenticate -func ReadSetupAuthenticate(buf []byte, v *SetupAuthenticate) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 5 // padding - - v.Length = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, (int(v.Length) * 4)) - copy(byteString[:(int(v.Length)*4)], buf[b:]) - v.Reason = string(byteString) - b += pad(int((int(v.Length) * 4))) - } - - return b -} - -// Struct list read SetupAuthenticate -func ReadSetupAuthenticateList(buf []byte, dest []SetupAuthenticate) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupAuthenticate{} - b += ReadSetupAuthenticate(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupAuthenticate -func (v SetupAuthenticate) Bytes() []byte { - buf := make([]byte, (8 + pad(((int(v.Length) * 4) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 5 // padding - - Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += pad(int((int(v.Length) * 4))) - - return buf -} - -// Write struct list SetupAuthenticate -func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupAuthenticate -func SetupAuthenticateListSize(list []SetupAuthenticate) int { - size := 0 - for _, item := range list { - size += (8 + pad(((int(item.Length) * 4) * 1))) - } - return size -} - -// 'SetupInfo' struct definition -// Size: (((40 + pad((int(VendorLen) * 1))) + pad((int(PixmapFormatsLen) * 8))) + ScreenInfoListSize(Roots)) -type SetupInfo struct { - Status byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - ReleaseNumber uint32 - ResourceIdBase uint32 - ResourceIdMask uint32 - MotionBufferSize uint32 - VendorLen uint16 - MaximumRequestLength uint16 - RootsLen byte - PixmapFormatsLen byte - ImageByteOrder byte - BitmapFormatBitOrder byte - BitmapFormatScanlineUnit byte - BitmapFormatScanlinePad byte - MinKeycode Keycode - MaxKeycode Keycode - // padding: 4 bytes - Vendor string // size: pad((int(VendorLen) * 1)) - PixmapFormats []Format // size: pad((int(PixmapFormatsLen) * 8)) - Roots []ScreenInfo // size: ScreenInfoListSize(Roots) -} - -// Struct read SetupInfo -func ReadSetupInfo(buf []byte, v *SetupInfo) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 1 // padding - - v.ProtocolMajorVersion = Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = Get16(buf[b:]) - b += 2 - - v.Length = Get16(buf[b:]) - b += 2 - - v.ReleaseNumber = Get32(buf[b:]) - b += 4 - - v.ResourceIdBase = Get32(buf[b:]) - b += 4 - - v.ResourceIdMask = Get32(buf[b:]) - b += 4 - - v.MotionBufferSize = Get32(buf[b:]) - b += 4 - - v.VendorLen = Get16(buf[b:]) - b += 2 - - v.MaximumRequestLength = Get16(buf[b:]) - b += 2 - - v.RootsLen = buf[b] - b += 1 - - v.PixmapFormatsLen = buf[b] - b += 1 - - v.ImageByteOrder = buf[b] - b += 1 - - v.BitmapFormatBitOrder = buf[b] - b += 1 - - v.BitmapFormatScanlineUnit = buf[b] - b += 1 - - v.BitmapFormatScanlinePad = buf[b] - b += 1 - - v.MinKeycode = Keycode(buf[b]) - b += 1 - - v.MaxKeycode = Keycode(buf[b]) - b += 1 - - b += 4 // padding - - { - byteString := make([]byte, v.VendorLen) - copy(byteString[:v.VendorLen], buf[b:]) - v.Vendor = string(byteString) - b += pad(int(v.VendorLen)) - } - - v.PixmapFormats = make([]Format, v.PixmapFormatsLen) - b += ReadFormatList(buf[b:], v.PixmapFormats) - - v.Roots = make([]ScreenInfo, v.RootsLen) - b += ReadScreenInfoList(buf[b:], v.Roots) - - return b -} - -// Struct list read SetupInfo -func ReadSetupInfoList(buf []byte, dest []SetupInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupInfo{} - b += ReadSetupInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupInfo -func (v SetupInfo) Bytes() []byte { - buf := make([]byte, (((40 + pad((int(v.VendorLen) * 1))) + pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - Put16(buf[b:], v.Length) - b += 2 - - Put32(buf[b:], v.ReleaseNumber) - b += 4 - - Put32(buf[b:], v.ResourceIdBase) - b += 4 - - Put32(buf[b:], v.ResourceIdMask) - b += 4 - - Put32(buf[b:], v.MotionBufferSize) - b += 4 - - Put16(buf[b:], v.VendorLen) - b += 2 - - Put16(buf[b:], v.MaximumRequestLength) - b += 2 - - buf[b] = v.RootsLen - b += 1 - - buf[b] = v.PixmapFormatsLen - b += 1 - - buf[b] = v.ImageByteOrder - b += 1 - - buf[b] = v.BitmapFormatBitOrder - b += 1 - - buf[b] = v.BitmapFormatScanlineUnit - b += 1 - - buf[b] = v.BitmapFormatScanlinePad - b += 1 - - buf[b] = byte(v.MinKeycode) - b += 1 - - buf[b] = byte(v.MaxKeycode) - b += 1 - - b += 4 // padding - - copy(buf[b:], v.Vendor[:v.VendorLen]) - b += pad(int(v.VendorLen)) - - b += FormatListBytes(buf[b:], v.PixmapFormats) - - b += ScreenInfoListBytes(buf[b:], v.Roots) - - return buf -} - -// Write struct list SetupInfo -func SetupInfoListBytes(buf []byte, list []SetupInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupInfo -func SetupInfoListSize(list []SetupInfo) int { - size := 0 - for _, item := range list { - size += (((40 + pad((int(item.VendorLen) * 1))) + pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) - } - return size -} - -// 'Timecoord' struct definition -// Size: 8 -type Timecoord struct { - Time Timestamp - X int16 - Y int16 -} - -// Struct read Timecoord -func ReadTimecoord(buf []byte, v *Timecoord) int { - b := 0 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Timecoord -func ReadTimecoordList(buf []byte, dest []Timecoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Timecoord{} - b += ReadTimecoord(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Timecoord -func (v Timecoord) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// Write struct list Timecoord -func TimecoordListBytes(buf []byte, list []Timecoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Fontprop' struct definition -// Size: 8 -type Fontprop struct { - Name Atom - Value uint32 -} - -// Struct read Fontprop -func ReadFontprop(buf []byte, v *Fontprop) int { - b := 0 - - v.Name = Atom(Get32(buf[b:])) - b += 4 - - v.Value = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Fontprop -func ReadFontpropList(buf []byte, dest []Fontprop) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Fontprop{} - b += ReadFontprop(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Fontprop -func (v Fontprop) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Name)) - b += 4 - - Put32(buf[b:], v.Value) - b += 4 - - return buf -} - -// Write struct list Fontprop -func FontpropListBytes(buf []byte, list []Fontprop) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Charinfo' struct definition -// Size: 12 -type Charinfo struct { - LeftSideBearing int16 - RightSideBearing int16 - CharacterWidth int16 - Ascent int16 - Descent int16 - Attributes uint16 -} - -// Struct read Charinfo -func ReadCharinfo(buf []byte, v *Charinfo) int { - b := 0 - - v.LeftSideBearing = int16(Get16(buf[b:])) - b += 2 - - v.RightSideBearing = int16(Get16(buf[b:])) - b += 2 - - v.CharacterWidth = int16(Get16(buf[b:])) - b += 2 - - v.Ascent = int16(Get16(buf[b:])) - b += 2 - - v.Descent = int16(Get16(buf[b:])) - b += 2 - - v.Attributes = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read Charinfo -func ReadCharinfoList(buf []byte, dest []Charinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Charinfo{} - b += ReadCharinfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Charinfo -func (v Charinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put16(buf[b:], uint16(v.LeftSideBearing)) - b += 2 - - Put16(buf[b:], uint16(v.RightSideBearing)) - b += 2 - - Put16(buf[b:], uint16(v.CharacterWidth)) - b += 2 - - Put16(buf[b:], uint16(v.Ascent)) - b += 2 - - Put16(buf[b:], uint16(v.Descent)) - b += 2 - - Put16(buf[b:], v.Attributes) - b += 2 - - return buf -} - -// Write struct list Charinfo -func CharinfoListBytes(buf []byte, list []Charinfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Str' struct definition -// Size: (1 + pad((int(NameLen) * 1))) -type Str struct { - NameLen byte - Name string // size: pad((int(NameLen) * 1)) -} - -// Struct read Str -func ReadStr(buf []byte, v *Str) int { - b := 0 - - v.NameLen = buf[b] - b += 1 - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return b -} - -// Struct list read Str -func ReadStrList(buf []byte, dest []Str) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Str{} - b += ReadStr(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Str -func (v Str) Bytes() []byte { - buf := make([]byte, (1 + pad((int(v.NameLen) * 1)))) - b := 0 - - buf[b] = v.NameLen - b += 1 - - copy(buf[b:], v.Name[:v.NameLen]) - b += pad(int(v.NameLen)) - - return buf -} - -// Write struct list Str -func StrListBytes(buf []byte, list []Str) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size Str -func StrListSize(list []Str) int { - size := 0 - for _, item := range list { - size += (1 + pad((int(item.NameLen) * 1))) - } - return size -} - -// 'Segment' struct definition -// Size: 8 -type Segment struct { - X1 int16 - Y1 int16 - X2 int16 - Y2 int16 -} - -// Struct read Segment -func ReadSegment(buf []byte, v *Segment) int { - b := 0 - - v.X1 = int16(Get16(buf[b:])) - b += 2 - - v.Y1 = int16(Get16(buf[b:])) - b += 2 - - v.X2 = int16(Get16(buf[b:])) - b += 2 - - v.Y2 = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Segment -func ReadSegmentList(buf []byte, dest []Segment) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Segment{} - b += ReadSegment(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Segment -func (v Segment) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.X1)) - b += 2 - - Put16(buf[b:], uint16(v.Y1)) - b += 2 - - Put16(buf[b:], uint16(v.X2)) - b += 2 - - Put16(buf[b:], uint16(v.Y2)) - b += 2 - - return buf -} - -// Write struct list Segment -func SegmentListBytes(buf []byte, list []Segment) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Coloritem' struct definition -// Size: 12 -type Coloritem struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Flags byte - // padding: 1 bytes -} - -// Struct read Coloritem -func ReadColoritem(buf []byte, v *Coloritem) int { - b := 0 - - v.Pixel = Get32(buf[b:]) - b += 4 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - v.Flags = buf[b] - b += 1 - - b += 1 // padding - - return b -} - -// Struct list read Coloritem -func ReadColoritemList(buf []byte, dest []Coloritem) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Coloritem{} - b += ReadColoritem(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Coloritem -func (v Coloritem) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], v.Pixel) - b += 4 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - buf[b] = v.Flags - b += 1 - - b += 1 // padding - - return buf -} - -// Write struct list Coloritem -func ColoritemListBytes(buf []byte, list []Coloritem) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Rgb' struct definition -// Size: 8 -type Rgb struct { - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes -} - -// Struct read Rgb -func ReadRgb(buf []byte, v *Rgb) int { - b := 0 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return b -} - -// Struct list read Rgb -func ReadRgbList(buf []byte, dest []Rgb) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rgb{} - b += ReadRgb(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Rgb -func (v Rgb) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - b += 2 // padding - - return buf -} - -// Write struct list Rgb -func RgbListBytes(buf []byte, list []Rgb) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Host' struct definition -// Size: (4 + pad((int(AddressLen) * 1))) -type Host struct { - Family byte - // padding: 1 bytes - AddressLen uint16 - Address []byte // size: pad((int(AddressLen) * 1)) -} - -// Struct read Host -func ReadHost(buf []byte, v *Host) int { - b := 0 - - v.Family = buf[b] - b += 1 - - b += 1 // padding - - v.AddressLen = Get16(buf[b:]) - b += 2 - - v.Address = make([]byte, v.AddressLen) - copy(v.Address[:v.AddressLen], buf[b:]) - b += pad(int(v.AddressLen)) - - return b -} - -// Struct list read Host -func ReadHostList(buf []byte, dest []Host) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Host{} - b += ReadHost(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Host -func (v Host) Bytes() []byte { - buf := make([]byte, (4 + pad((int(v.AddressLen) * 1)))) - b := 0 - - buf[b] = v.Family - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.AddressLen) - b += 2 - - copy(buf[b:], v.Address[:v.AddressLen]) - b += pad(int(v.AddressLen)) - - return buf -} - -// Write struct list Host -func HostListBytes(buf []byte, list []Host) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size Host -func HostListSize(list []Host) int { - size := 0 - for _, item := range list { - size += (4 + pad((int(item.AddressLen) * 1))) - } - return size -} - -// Union definition ClientMessageDataUnion -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'ClientMessageDataUnion': -// NewClientMessageDataUnionData8(Data8 []byte) ClientMessageDataUnion -// NewClientMessageDataUnionData16(Data16 []uint16) ClientMessageDataUnion -// NewClientMessageDataUnionData32(Data32 []uint32) ClientMessageDataUnion -type ClientMessageDataUnion struct { - Data8 []byte // size: 20 - Data16 []uint16 // size: 20 - Data32 []uint32 // size: 20 -} - -// Union constructor for ClientMessageDataUnion for field Data8. -func NewClientMessageDataUnionData8(Data8 []byte) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) - - copy(buf[b:], Data8[:20]) - b += pad(int(20)) - - // Create the Union type - v := ClientMessageDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Union constructor for ClientMessageDataUnion for field Data16. -func NewClientMessageDataUnionData16(Data16 []uint16) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) - - for i := 0; i < int(10); i++ { - Put16(buf[b:], Data16[i]) - b += 2 - } - b = pad(b) - - // Create the Union type - v := ClientMessageDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Union constructor for ClientMessageDataUnion for field Data32. -func NewClientMessageDataUnionData32(Data32 []uint32) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) - - for i := 0; i < int(5); i++ { - Put32(buf[b:], Data32[i]) - b += 4 - } - b = pad(b) - - // Create the Union type - v := ClientMessageDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Union read ClientMessageDataUnion -func ReadClientMessageDataUnion(buf []byte, v *ClientMessageDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // re-read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // re-read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return 20 -} - -// Union list read ClientMessageDataUnion -func ReadClientMessageDataUnionList(buf []byte, dest []ClientMessageDataUnion) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ClientMessageDataUnion{} - b += ReadClientMessageDataUnion(buf[b:], &dest[i]) - } - return pad(b) -} - -// Union write ClientMessageDataUnion -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v ClientMessageDataUnion) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - copy(buf[b:], v.Data8[:20]) - b += pad(int(20)) - return buf -} - -// Union list write ClientMessageDataUnion -func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { - b := 0 - var unionBytes []byte - for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - return b -} - -// Event definition KeyPress (2) -// Size: 32 - -const KeyPress = 2 - -type KeyPressEvent struct { - Sequence uint16 - Detail Keycode - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes -} - -// Event read KeyPress -func NewKeyPressEvent(buf []byte) Event { - v := KeyPressEvent{} - b := 1 // don't read event number - - v.Detail = Keycode(buf[b]) - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write KeyPress -func (v KeyPressEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 2 - b += 1 - - buf[b] = byte(v.Detail) - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v KeyPressEvent) ImplementsEvent() {} - -func (v KeyPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v KeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "KeyPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[2] = NewKeyPressEvent -} - -// Event definition ButtonPress (4) -// Size: 32 - -const ButtonPress = 4 - -type ButtonPressEvent struct { - Sequence uint16 - Detail Button - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes -} - -// Event read ButtonPress -func NewButtonPressEvent(buf []byte) Event { - v := ButtonPressEvent{} - b := 1 // don't read event number - - v.Detail = Button(buf[b]) - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write ButtonPress -func (v ButtonPressEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 4 - b += 1 - - buf[b] = byte(v.Detail) - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v ButtonPressEvent) ImplementsEvent() {} - -func (v ButtonPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[4] = NewButtonPressEvent -} - -// Event definition MotionNotify (6) -// Size: 32 - -const MotionNotify = 6 - -type MotionNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes -} - -// Event read MotionNotify -func NewMotionNotifyEvent(buf []byte) Event { - v := MotionNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write MotionNotify -func (v MotionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 6 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v MotionNotifyEvent) ImplementsEvent() {} - -func (v MotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "MotionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[6] = NewMotionNotifyEvent -} - -// Event definition EnterNotify (7) -// Size: 32 - -const EnterNotify = 7 - -type EnterNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - Mode byte - SameScreenFocus byte -} - -// Event read EnterNotify -func NewEnterNotifyEvent(buf []byte) Event { - v := EnterNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - v.Mode = buf[b] - b += 1 - - v.SameScreenFocus = buf[b] - b += 1 - - return v -} - -// Event write EnterNotify -func (v EnterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 7 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - buf[b] = v.Mode - b += 1 - - buf[b] = v.SameScreenFocus - b += 1 - - return buf -} - -func (v EnterNotifyEvent) ImplementsEvent() {} - -func (v EnterNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v EnterNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "EnterNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[7] = NewEnterNotifyEvent -} - -// Event definition FocusIn (9) -// Size: 32 - -const FocusIn = 9 - -type FocusInEvent struct { - Sequence uint16 - Detail byte - Event Window - Mode byte - // padding: 3 bytes -} - -// Event read FocusIn -func NewFocusInEvent(buf []byte) Event { - v := FocusInEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Mode = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write FocusIn -func (v FocusInEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 9 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - buf[b] = v.Mode - b += 1 - - b += 3 // padding - - return buf -} - -func (v FocusInEvent) ImplementsEvent() {} - -func (v FocusInEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v FocusInEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - return "FocusIn {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[9] = NewFocusInEvent -} - -// Event definition KeymapNotify (11) -// Size: 32 - -const KeymapNotify = 11 - -type KeymapNotifyEvent struct { - Keys []byte // size: 32 -} - -// Event read KeymapNotify -func NewKeymapNotifyEvent(buf []byte) Event { - v := KeymapNotifyEvent{} - b := 1 // don't read event number - - v.Keys = make([]byte, 31) - copy(v.Keys[:31], buf[b:]) - b += pad(int(31)) - - return v -} - -// Event write KeymapNotify -func (v KeymapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 11 - b += 1 - - copy(buf[b:], v.Keys[:31]) - b += pad(int(31)) - - return buf -} - -func (v KeymapNotifyEvent) ImplementsEvent() {} - -func (v KeymapNotifyEvent) SequenceId() uint16 { - return uint16(0) -} - -func (v KeymapNotifyEvent) String() string { - fieldVals := make([]string, 0, 1) - return "KeymapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[11] = NewKeymapNotifyEvent -} - -// Event definition Expose (12) -// Size: 32 - -const Expose = 12 - -type ExposeEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 2 bytes -} - -// Event read Expose -func NewExposeEvent(buf []byte) Event { - v := ExposeEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.X = Get16(buf[b:]) - b += 2 - - v.Y = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Count = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -// Event write Expose -func (v ExposeEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 12 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], v.X) - b += 2 - - Put16(buf[b:], v.Y) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Count) - b += 2 - - b += 2 // padding - - return buf -} - -func (v ExposeEvent) ImplementsEvent() {} - -func (v ExposeEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ExposeEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - return "Expose {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[12] = NewExposeEvent -} - -// Event definition GraphicsExposure (13) -// Size: 32 - -const GraphicsExposure = 13 - -type GraphicsExposureEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable - X uint16 - Y uint16 - Width uint16 - Height uint16 - MinorOpcode uint16 - Count uint16 - MajorOpcode byte - // padding: 3 bytes -} - -// Event read GraphicsExposure -func NewGraphicsExposureEvent(buf []byte) Event { - v := GraphicsExposureEvent{} - 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.X = Get16(buf[b:]) - b += 2 - - v.Y = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.Count = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write GraphicsExposure -func (v GraphicsExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put16(buf[b:], v.X) - b += 2 - - Put16(buf[b:], v.Y) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.MinorOpcode) - b += 2 - - Put16(buf[b:], v.Count) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 3 // padding - - return buf -} - -func (v GraphicsExposureEvent) ImplementsEvent() {} - -func (v GraphicsExposureEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v GraphicsExposureEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "GraphicsExposure {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[13] = NewGraphicsExposureEvent -} - -// Event definition NoExposure (14) -// Size: 32 - -const NoExposure = 14 - -type NoExposureEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// Event read NoExposure -func NewNoExposureEvent(buf []byte) Event { - v := NoExposureEvent{} - 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.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -// Event write NoExposure -func (v NoExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put16(buf[b:], v.MinorOpcode) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 1 // padding - - return buf -} - -func (v NoExposureEvent) ImplementsEvent() {} - -func (v NoExposureEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v NoExposureEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "NoExposure {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[14] = NewNoExposureEvent -} - -// Event definition VisibilityNotify (15) -// Size: 32 - -const VisibilityNotify = 15 - -type VisibilityNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - State byte - // padding: 3 bytes -} - -// Event read VisibilityNotify -func NewVisibilityNotifyEvent(buf []byte) Event { - v := VisibilityNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write VisibilityNotify -func (v VisibilityNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 15 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - - return buf -} - -func (v VisibilityNotifyEvent) ImplementsEvent() {} - -func (v VisibilityNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v VisibilityNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "VisibilityNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[15] = NewVisibilityNotifyEvent -} - -// Event definition CreateNotify (16) -// Size: 32 - -const CreateNotify = 16 - -type CreateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool - // padding: 1 bytes -} - -// Event read CreateNotify -func NewCreateNotifyEvent(buf []byte) Event { - v := CreateNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write CreateNotify -func (v CreateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 16 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.BorderWidth) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v CreateNotifyEvent) ImplementsEvent() {} - -func (v CreateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v CreateNotifyEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "CreateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[16] = NewCreateNotifyEvent -} - -// Event definition DestroyNotify (17) -// Size: 32 - -const DestroyNotify = 17 - -type DestroyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window -} - -// Event read DestroyNotify -func NewDestroyNotifyEvent(buf []byte) Event { - v := DestroyNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write DestroyNotify -func (v DestroyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 17 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - return buf -} - -func (v DestroyNotifyEvent) ImplementsEvent() {} - -func (v DestroyNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v DestroyNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - return "DestroyNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[17] = NewDestroyNotifyEvent -} - -// Event definition UnmapNotify (18) -// Size: 32 - -const UnmapNotify = 18 - -type UnmapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - FromConfigure bool - // padding: 3 bytes -} - -// Event read UnmapNotify -func NewUnmapNotifyEvent(buf []byte) Event { - v := UnmapNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.FromConfigure = true - } else { - v.FromConfigure = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Event write UnmapNotify -func (v UnmapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 18 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - if v.FromConfigure { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -func (v UnmapNotifyEvent) ImplementsEvent() {} - -func (v UnmapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v UnmapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("FromConfigure: %t", v.FromConfigure)) - return "UnmapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[18] = NewUnmapNotifyEvent -} - -// Event definition MapNotify (19) -// Size: 32 - -const MapNotify = 19 - -type MapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - OverrideRedirect bool - // padding: 3 bytes -} - -// Event read MapNotify -func NewMapNotifyEvent(buf []byte) Event { - v := MapNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Event write MapNotify -func (v MapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 19 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -func (v MapNotifyEvent) ImplementsEvent() {} - -func (v MapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "MapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[19] = NewMapNotifyEvent -} - -// Event definition MapRequest (20) -// Size: 32 - -const MapRequest = 20 - -type MapRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window -} - -// Event read MapRequest -func NewMapRequestEvent(buf []byte) Event { - v := MapRequestEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write MapRequest -func (v MapRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 20 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - return buf -} - -func (v MapRequestEvent) ImplementsEvent() {} - -func (v MapRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MapRequestEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - return "MapRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[20] = NewMapRequestEvent -} - -// Event definition ReparentNotify (21) -// Size: 32 - -const ReparentNotify = 21 - -type ReparentNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - Parent Window - X int16 - Y int16 - OverrideRedirect bool - // padding: 3 bytes -} - -// Event read ReparentNotify -func NewReparentNotifyEvent(buf []byte) Event { - v := ReparentNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Event write ReparentNotify -func (v ReparentNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 21 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -func (v ReparentNotifyEvent) ImplementsEvent() {} - -func (v ReparentNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ReparentNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ReparentNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[21] = NewReparentNotifyEvent -} - -// Event definition ConfigureNotify (22) -// Size: 32 - -const ConfigureNotify = 22 - -type ConfigureNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - AboveSibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool - // padding: 1 bytes -} - -// Event read ConfigureNotify -func NewConfigureNotifyEvent(buf []byte) Event { - v := ConfigureNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.AboveSibling = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write ConfigureNotify -func (v ConfigureNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 22 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.AboveSibling)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.BorderWidth) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v ConfigureNotifyEvent) ImplementsEvent() {} - -func (v ConfigureNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ConfigureNotifyEvent) String() string { - fieldVals := make([]string, 0, 11) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("AboveSibling: %d", v.AboveSibling)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ConfigureNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[22] = NewConfigureNotifyEvent -} - -// Event definition ConfigureRequest (23) -// Size: 32 - -const ConfigureRequest = 23 - -type ConfigureRequestEvent struct { - Sequence uint16 - StackMode byte - Parent Window - Window Window - Sibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - ValueMask uint16 -} - -// Event read ConfigureRequest -func NewConfigureRequestEvent(buf []byte) Event { - v := ConfigureRequestEvent{} - b := 1 // don't read event number - - v.StackMode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Sibling = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - v.ValueMask = Get16(buf[b:]) - b += 2 - - return v -} - -// Event write ConfigureRequest -func (v ConfigureRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 23 - b += 1 - - buf[b] = v.StackMode - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Sibling)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.BorderWidth) - b += 2 - - Put16(buf[b:], v.ValueMask) - b += 2 - - return buf -} - -func (v ConfigureRequestEvent) ImplementsEvent() {} - -func (v ConfigureRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ConfigureRequestEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("StackMode: %d", v.StackMode)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Sibling: %d", v.Sibling)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, sprintf("ValueMask: %d", v.ValueMask)) - return "ConfigureRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[23] = NewConfigureRequestEvent -} - -// Event definition GravityNotify (24) -// Size: 32 - -const GravityNotify = 24 - -type GravityNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - X int16 - Y int16 -} - -// Event read GravityNotify -func NewGravityNotifyEvent(buf []byte) Event { - v := GravityNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - return v -} - -// Event write GravityNotify -func (v GravityNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 24 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -func (v GravityNotifyEvent) ImplementsEvent() {} - -func (v GravityNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v GravityNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - return "GravityNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[24] = NewGravityNotifyEvent -} - -// Event definition ResizeRequest (25) -// Size: 32 - -const ResizeRequest = 25 - -type ResizeRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Width uint16 - Height uint16 -} - -// Event read ResizeRequest -func NewResizeRequestEvent(buf []byte) Event { - v := ResizeRequestEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return v -} - -// Event write ResizeRequest -func (v ResizeRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 25 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -func (v ResizeRequestEvent) ImplementsEvent() {} - -func (v ResizeRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ResizeRequestEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - return "ResizeRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[25] = NewResizeRequestEvent -} - -// Event definition CirculateNotify (26) -// Size: 32 - -const CirculateNotify = 26 - -type CirculateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - // padding: 4 bytes - Place byte - // padding: 3 bytes -} - -// Event read CirculateNotify -func NewCirculateNotifyEvent(buf []byte) Event { - v := CirculateNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - b += 4 // padding - - v.Place = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write CirculateNotify -func (v CirculateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 26 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - b += 4 // padding - - buf[b] = v.Place - b += 1 - - b += 3 // padding - - return buf -} - -func (v CirculateNotifyEvent) ImplementsEvent() {} - -func (v CirculateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v CirculateNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Place: %d", v.Place)) - return "CirculateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[26] = NewCirculateNotifyEvent -} - -// Event definition PropertyNotify (28) -// Size: 32 - -const PropertyNotify = 28 - -type PropertyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Atom Atom - Time Timestamp - State byte - // padding: 3 bytes -} - -// Event read PropertyNotify -func NewPropertyNotifyEvent(buf []byte) Event { - v := PropertyNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Atom = Atom(Get32(buf[b:])) - b += 4 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write PropertyNotify -func (v PropertyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 28 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Atom)) - b += 4 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - - return buf -} - -func (v PropertyNotifyEvent) ImplementsEvent() {} - -func (v PropertyNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v PropertyNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Atom: %d", v.Atom)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "PropertyNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[28] = NewPropertyNotifyEvent -} - -// Event definition SelectionClear (29) -// Size: 32 - -const SelectionClear = 29 - -type SelectionClearEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Owner Window - Selection Atom -} - -// Event read SelectionClear -func NewSelectionClearEvent(buf []byte) Event { - v := SelectionClearEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write SelectionClear -func (v SelectionClearEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 29 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Owner)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - return buf -} - -func (v SelectionClearEvent) ImplementsEvent() {} - -func (v SelectionClearEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SelectionClearEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - return "SelectionClear {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[29] = NewSelectionClearEvent -} - -// Event definition SelectionRequest (30) -// Size: 32 - -const SelectionRequest = 30 - -type SelectionRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Owner Window - Requestor Window - Selection Atom - Target Atom - Property Atom -} - -// Event read SelectionRequest -func NewSelectionRequestEvent(buf []byte) Event { - v := SelectionRequestEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - v.Requestor = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - v.Target = Atom(Get32(buf[b:])) - b += 4 - - v.Property = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write SelectionRequest -func (v SelectionRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 30 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Owner)) - b += 4 - - Put32(buf[b:], uint32(v.Requestor)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - Put32(buf[b:], uint32(v.Target)) - b += 4 - - Put32(buf[b:], uint32(v.Property)) - b += 4 - - return buf -} - -func (v SelectionRequestEvent) ImplementsEvent() {} - -func (v SelectionRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SelectionRequestEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, sprintf("Requestor: %d", v.Requestor)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, sprintf("Target: %d", v.Target)) - fieldVals = append(fieldVals, sprintf("Property: %d", v.Property)) - return "SelectionRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[30] = NewSelectionRequestEvent -} - -// Event definition SelectionNotify (31) -// Size: 32 - -const SelectionNotify = 31 - -type SelectionNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Requestor Window - Selection Atom - Target Atom - Property Atom -} - -// Event read SelectionNotify -func NewSelectionNotifyEvent(buf []byte) Event { - v := SelectionNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Requestor = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - v.Target = Atom(Get32(buf[b:])) - b += 4 - - v.Property = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write SelectionNotify -func (v SelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 31 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Requestor)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - Put32(buf[b:], uint32(v.Target)) - b += 4 - - Put32(buf[b:], uint32(v.Property)) - b += 4 - - return buf -} - -func (v SelectionNotifyEvent) ImplementsEvent() {} - -func (v SelectionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SelectionNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Requestor: %d", v.Requestor)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, sprintf("Target: %d", v.Target)) - fieldVals = append(fieldVals, sprintf("Property: %d", v.Property)) - return "SelectionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[31] = NewSelectionNotifyEvent -} - -// Event definition ColormapNotify (32) -// Size: 32 - -const ColormapNotify = 32 - -type ColormapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Colormap Colormap - New bool - State byte - // padding: 2 bytes -} - -// Event read ColormapNotify -func NewColormapNotifyEvent(buf []byte) Event { - v := ColormapNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Colormap = Colormap(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.New = true - } else { - v.New = false - } - b += 1 - - v.State = buf[b] - b += 1 - - b += 2 // padding - - return v -} - -// Event write ColormapNotify -func (v ColormapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 32 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Colormap)) - b += 4 - - if v.New { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.State - b += 1 - - b += 2 // padding - - return buf -} - -func (v ColormapNotifyEvent) ImplementsEvent() {} - -func (v ColormapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ColormapNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Colormap: %d", v.Colormap)) - fieldVals = append(fieldVals, sprintf("New: %t", v.New)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "ColormapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[32] = NewColormapNotifyEvent -} - -// Event definition ClientMessage (33) -// Size: 32 - -const ClientMessage = 33 - -type ClientMessageEvent struct { - Sequence uint16 - Format byte - Window Window - Type Atom - Data ClientMessageDataUnion -} - -// Event read ClientMessage -func NewClientMessageEvent(buf []byte) Event { - v := ClientMessageEvent{} - b := 1 // don't read event number - - v.Format = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Type = Atom(Get32(buf[b:])) - b += 4 - - v.Data = ClientMessageDataUnion{} - b += ReadClientMessageDataUnion(buf[b:], &v.Data) - - return v -} - -// Event write ClientMessage -func (v ClientMessageEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 33 - b += 1 - - buf[b] = v.Format - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Type)) - b += 4 - - { - unionBytes := v.Data.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - - return buf -} - -func (v ClientMessageEvent) ImplementsEvent() {} - -func (v ClientMessageEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ClientMessageEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Format: %d", v.Format)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Type: %d", v.Type)) - return "ClientMessage {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[33] = NewClientMessageEvent -} - -// Event definition MappingNotify (34) -// Size: 32 - -const MappingNotify = 34 - -type MappingNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Request byte - FirstKeycode Keycode - Count byte - // padding: 1 bytes -} - -// Event read MappingNotify -func NewMappingNotifyEvent(buf []byte) Event { - v := MappingNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Request = buf[b] - b += 1 - - v.FirstKeycode = Keycode(buf[b]) - b += 1 - - v.Count = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -// Event write MappingNotify -func (v MappingNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 34 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 - - buf[b] = v.Count - b += 1 - - b += 1 // padding - - return buf -} - -func (v MappingNotifyEvent) ImplementsEvent() {} - -func (v MappingNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - return "MappingNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[34] = NewMappingNotifyEvent -} - -// EventCopy definition KeyRelease (3) - -const KeyRelease = 3 - -type KeyReleaseEvent KeyPressEvent - -func NewKeyReleaseEvent(buf []byte) Event { - return KeyReleaseEvent(NewKeyPressEvent(buf).(KeyPressEvent)) -} - -func (v KeyReleaseEvent) Bytes() []byte { - return KeyPressEvent(v).Bytes() -} - -func (v KeyReleaseEvent) ImplementsEvent() {} - -func (v KeyReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v KeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "KeyRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[3] = NewKeyReleaseEvent -} - -// EventCopy definition ButtonRelease (5) - -const ButtonRelease = 5 - -type ButtonReleaseEvent ButtonPressEvent - -func NewButtonReleaseEvent(buf []byte) Event { - return ButtonReleaseEvent(NewButtonPressEvent(buf).(ButtonPressEvent)) -} - -func (v ButtonReleaseEvent) Bytes() []byte { - return ButtonPressEvent(v).Bytes() -} - -func (v ButtonReleaseEvent) ImplementsEvent() {} - -func (v ButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[5] = NewButtonReleaseEvent -} - -// EventCopy definition LeaveNotify (8) - -const LeaveNotify = 8 - -type LeaveNotifyEvent EnterNotifyEvent - -func NewLeaveNotifyEvent(buf []byte) Event { - return LeaveNotifyEvent(NewEnterNotifyEvent(buf).(EnterNotifyEvent)) -} - -func (v LeaveNotifyEvent) Bytes() []byte { - return EnterNotifyEvent(v).Bytes() -} - -func (v LeaveNotifyEvent) ImplementsEvent() {} - -func (v LeaveNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v LeaveNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "LeaveNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[8] = NewLeaveNotifyEvent -} - -// EventCopy definition FocusOut (10) - -const FocusOut = 10 - -type FocusOutEvent FocusInEvent - -func NewFocusOutEvent(buf []byte) Event { - return FocusOutEvent(NewFocusInEvent(buf).(FocusInEvent)) -} - -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} - -func (v FocusOutEvent) ImplementsEvent() {} - -func (v FocusOutEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v FocusOutEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - return "FocusOut {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[10] = NewFocusOutEvent -} - -// EventCopy definition CirculateRequest (27) - -const CirculateRequest = 27 - -type CirculateRequestEvent CirculateNotifyEvent - -func NewCirculateRequestEvent(buf []byte) Event { - return CirculateRequestEvent(NewCirculateNotifyEvent(buf).(CirculateNotifyEvent)) -} - -func (v CirculateRequestEvent) Bytes() []byte { - return CirculateNotifyEvent(v).Bytes() -} - -func (v CirculateRequestEvent) ImplementsEvent() {} - -func (v CirculateRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v CirculateRequestEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Place: %d", v.Place)) - return "CirculateRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[27] = NewCirculateRequestEvent -} - -// Error definition Request (1) -// Size: 32 - -const BadRequest = 1 - -type RequestError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// Error read Request -func NewRequestError(buf []byte) Error { - v := RequestError{} - v.NiceName = "Request" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadValue = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -func (err RequestError) ImplementsError() {} - -func (err RequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err RequestError) BadId() uint32 { - return err.BadValue -} - -func (err RequestError) 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 "BadRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[1] = NewRequestError -} - -// Error definition Value (2) -// Size: 32 - -const BadValue = 2 - -type ValueError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// Error read Value -func NewValueError(buf []byte) Error { - v := ValueError{} - v.NiceName = "Value" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadValue = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -func (err ValueError) ImplementsError() {} - -func (err ValueError) SequenceId() uint16 { - return err.Sequence -} - -func (err ValueError) BadId() uint32 { - return err.BadValue -} - -func (err ValueError) 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 "BadValue {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[2] = NewValueError -} - -// ErrorCopy definition Window (3) - -const BadWindow = 3 - -type WindowError ValueError - -func NewWindowError(buf []byte) Error { - v := WindowError(NewValueError(buf).(ValueError)) - v.NiceName = "Window" - return v -} - -func (err WindowError) ImplementsError() {} - -func (err WindowError) SequenceId() uint16 { - return err.Sequence -} - -func (err WindowError) BadId() uint32 { - return err.BadValue -} - -func (err WindowError) 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 "BadWindow {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[3] = NewWindowError -} - -// ErrorCopy definition Pixmap (4) - -const BadPixmap = 4 - -type PixmapError ValueError - -func NewPixmapError(buf []byte) Error { - v := PixmapError(NewValueError(buf).(ValueError)) - v.NiceName = "Pixmap" - return v -} - -func (err PixmapError) ImplementsError() {} - -func (err PixmapError) SequenceId() uint16 { - return err.Sequence -} - -func (err PixmapError) BadId() uint32 { - return err.BadValue -} - -func (err PixmapError) 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 "BadPixmap {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[4] = NewPixmapError -} - -// ErrorCopy definition Atom (5) - -const BadAtom = 5 - -type AtomError ValueError - -func NewAtomError(buf []byte) Error { - v := AtomError(NewValueError(buf).(ValueError)) - v.NiceName = "Atom" - return v -} - -func (err AtomError) ImplementsError() {} - -func (err AtomError) SequenceId() uint16 { - return err.Sequence -} - -func (err AtomError) BadId() uint32 { - return err.BadValue -} - -func (err AtomError) 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 "BadAtom {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[5] = NewAtomError -} - -// ErrorCopy definition Cursor (6) - -const BadCursor = 6 - -type CursorError ValueError - -func NewCursorError(buf []byte) Error { - v := CursorError(NewValueError(buf).(ValueError)) - v.NiceName = "Cursor" - return v -} - -func (err CursorError) ImplementsError() {} - -func (err CursorError) SequenceId() uint16 { - return err.Sequence -} - -func (err CursorError) BadId() uint32 { - return err.BadValue -} - -func (err CursorError) 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 "BadCursor {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[6] = NewCursorError -} - -// ErrorCopy definition Font (7) - -const BadFont = 7 - -type FontError ValueError - -func NewFontError(buf []byte) Error { - v := FontError(NewValueError(buf).(ValueError)) - v.NiceName = "Font" - return v -} - -func (err FontError) ImplementsError() {} - -func (err FontError) SequenceId() uint16 { - return err.Sequence -} - -func (err FontError) BadId() uint32 { - return err.BadValue -} - -func (err FontError) 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 "BadFont {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[7] = NewFontError -} - -// ErrorCopy definition Match (8) - -const BadMatch = 8 - -type MatchError RequestError - -func NewMatchError(buf []byte) Error { - v := MatchError(NewRequestError(buf).(RequestError)) - v.NiceName = "Match" - return v -} - -func (err MatchError) ImplementsError() {} - -func (err MatchError) SequenceId() uint16 { - return err.Sequence -} - -func (err MatchError) BadId() uint32 { - return err.BadValue -} - -func (err MatchError) 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 "BadMatch {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[8] = NewMatchError -} - -// ErrorCopy definition Drawable (9) - -const BadDrawable = 9 - -type DrawableError ValueError - -func NewDrawableError(buf []byte) Error { - v := DrawableError(NewValueError(buf).(ValueError)) - v.NiceName = "Drawable" - return v -} - -func (err DrawableError) ImplementsError() {} - -func (err DrawableError) SequenceId() uint16 { - return err.Sequence -} - -func (err DrawableError) BadId() uint32 { - return err.BadValue -} - -func (err DrawableError) 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 "BadDrawable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[9] = NewDrawableError -} - -// ErrorCopy definition Access (10) - -const BadAccess = 10 - -type AccessError RequestError - -func NewAccessError(buf []byte) Error { - v := AccessError(NewRequestError(buf).(RequestError)) - v.NiceName = "Access" - return v -} - -func (err AccessError) ImplementsError() {} - -func (err AccessError) SequenceId() uint16 { - return err.Sequence -} - -func (err AccessError) BadId() uint32 { - return err.BadValue -} - -func (err AccessError) 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 "BadAccess {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[10] = NewAccessError -} - -// ErrorCopy definition Alloc (11) - -const BadAlloc = 11 - -type AllocError RequestError - -func NewAllocError(buf []byte) Error { - v := AllocError(NewRequestError(buf).(RequestError)) - v.NiceName = "Alloc" - return v -} - -func (err AllocError) ImplementsError() {} - -func (err AllocError) SequenceId() uint16 { - return err.Sequence -} - -func (err AllocError) BadId() uint32 { - return err.BadValue -} - -func (err AllocError) 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 "BadAlloc {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[11] = NewAllocError -} - -// ErrorCopy definition Colormap (12) - -const BadColormap = 12 - -type ColormapError ValueError - -func NewColormapError(buf []byte) Error { - v := ColormapError(NewValueError(buf).(ValueError)) - v.NiceName = "Colormap" - return v -} - -func (err ColormapError) ImplementsError() {} - -func (err ColormapError) SequenceId() uint16 { - return err.Sequence -} - -func (err ColormapError) BadId() uint32 { - return err.BadValue -} - -func (err ColormapError) 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 "BadColormap {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[12] = NewColormapError -} - -// ErrorCopy definition GContext (13) - -const BadGContext = 13 - -type GContextError ValueError - -func NewGContextError(buf []byte) Error { - v := GContextError(NewValueError(buf).(ValueError)) - v.NiceName = "GContext" - return v -} - -func (err GContextError) ImplementsError() {} - -func (err GContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err GContextError) BadId() uint32 { - return err.BadValue -} - -func (err GContextError) 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 "BadGContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[13] = NewGContextError -} - -// ErrorCopy definition IDChoice (14) - -const BadIDChoice = 14 - -type IDChoiceError ValueError - -func NewIDChoiceError(buf []byte) Error { - v := IDChoiceError(NewValueError(buf).(ValueError)) - v.NiceName = "IDChoice" - return v -} - -func (err IDChoiceError) ImplementsError() {} - -func (err IDChoiceError) SequenceId() uint16 { - return err.Sequence -} - -func (err IDChoiceError) BadId() uint32 { - return err.BadValue -} - -func (err IDChoiceError) 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 "BadIDChoice {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[14] = NewIDChoiceError -} - -// ErrorCopy definition Name (15) - -const BadName = 15 - -type NameError RequestError - -func NewNameError(buf []byte) Error { - v := NameError(NewRequestError(buf).(RequestError)) - v.NiceName = "Name" - return v -} - -func (err NameError) ImplementsError() {} - -func (err NameError) SequenceId() uint16 { - return err.Sequence -} - -func (err NameError) BadId() uint32 { - return err.BadValue -} - -func (err NameError) 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 "BadName {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[15] = NewNameError -} - -// ErrorCopy definition Length (16) - -const BadLength = 16 - -type LengthError RequestError - -func NewLengthError(buf []byte) Error { - v := LengthError(NewRequestError(buf).(RequestError)) - v.NiceName = "Length" - return v -} - -func (err LengthError) ImplementsError() {} - -func (err LengthError) SequenceId() uint16 { - return err.Sequence -} - -func (err LengthError) BadId() uint32 { - return err.BadValue -} - -func (err LengthError) 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 "BadLength {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[16] = NewLengthError -} - -// ErrorCopy definition Implementation (17) - -const BadImplementation = 17 - -type ImplementationError RequestError - -func NewImplementationError(buf []byte) Error { - v := ImplementationError(NewRequestError(buf).(RequestError)) - v.NiceName = "Implementation" - return v -} - -func (err ImplementationError) ImplementsError() {} - -func (err ImplementationError) SequenceId() uint16 { - return err.Sequence -} - -func (err ImplementationError) BadId() uint32 { - return err.BadValue -} - -func (err ImplementationError) 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 "BadImplementation {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[17] = NewImplementationError -} - -// Request CreateWindow -// size: pad((28 + (4 + pad((4 * popCount(int(ValueMask))))))) -type CreateWindowCookie struct { - *cookie -} - -// Write request to wire for CreateWindow -func (c *Conn) CreateWindow(Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createWindowRequest(Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} -} - -func (c *Conn) CreateWindowChecked(Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createWindowRequest(Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} -} - -func (cook CreateWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateWindow -func (c *Conn) createWindowRequest(Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { - size := pad((28 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 1 // request opcode - b += 1 - - buf[b] = Depth - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Wid)) - b += 4 - - Put32(buf[b:], uint32(Parent)) - 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 - - Put16(buf[b:], Class) - b += 2 - - 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 ChangeWindowAttributes -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ChangeWindowAttributesCookie struct { - *cookie -} - -// Write request to wire for ChangeWindowAttributes -func (c *Conn) ChangeWindowAttributes(Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeWindowAttributesRequest(Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} -} - -func (c *Conn) ChangeWindowAttributesChecked(Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeWindowAttributesRequest(Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} -} - -func (cook ChangeWindowAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeWindowAttributes -func (c *Conn) changeWindowAttributesRequest(Window Window, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 2 // request opcode - b += 1 - - b += 1 // padding - - 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:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GetWindowAttributes -// size: 8 -type GetWindowAttributesCookie struct { - *cookie -} - -func (c *Conn) GetWindowAttributes(Window Window) GetWindowAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getWindowAttributesRequest(Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -func (c *Conn) GetWindowAttributesUnchecked(Window Window) GetWindowAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getWindowAttributesRequest(Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -// Request reply for GetWindowAttributes -// size: 44 -type GetWindowAttributesReply struct { - Sequence uint16 - Length uint32 - BackingStore byte - Visual Visualid - Class uint16 - BitGravity byte - WinGravity byte - BackingPlanes uint32 - BackingPixel uint32 - SaveUnder bool - MapIsInstalled bool - MapState byte - OverrideRedirect bool - Colormap Colormap - AllEventMasks uint32 - YourEventMask uint32 - DoNotPropagateMask uint16 - // padding: 2 bytes -} - -// Waits and reads reply data from request GetWindowAttributes -func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getWindowAttributesReply(buf), nil -} - -// Read reply into structure from buffer for GetWindowAttributes -func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { - v := new(GetWindowAttributesReply) - b := 1 // skip reply determinant - - v.BackingStore = 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.Class = Get16(buf[b:]) - b += 2 - - v.BitGravity = buf[b] - b += 1 - - v.WinGravity = buf[b] - b += 1 - - v.BackingPlanes = Get32(buf[b:]) - b += 4 - - v.BackingPixel = Get32(buf[b:]) - b += 4 - - if buf[b] == 1 { - v.SaveUnder = true - } else { - v.SaveUnder = false - } - b += 1 - - if buf[b] == 1 { - v.MapIsInstalled = true - } else { - v.MapIsInstalled = false - } - b += 1 - - v.MapState = buf[b] - b += 1 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - v.Colormap = Colormap(Get32(buf[b:])) - b += 4 - - v.AllEventMasks = Get32(buf[b:]) - b += 4 - - v.YourEventMask = Get32(buf[b:]) - b += 4 - - v.DoNotPropagateMask = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -func (cook GetWindowAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetWindowAttributes -func (c *Conn) getWindowAttributesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 3 // request opcode - b += 1 - - b += 1 // padding - - 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 DestroyWindow -// size: 8 -type DestroyWindowCookie struct { - *cookie -} - -// Write request to wire for DestroyWindow -func (c *Conn) DestroyWindow(Window Window) DestroyWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.destroyWindowRequest(Window), cookie) - return DestroyWindowCookie{cookie} -} - -func (c *Conn) DestroyWindowChecked(Window Window) DestroyWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.destroyWindowRequest(Window), cookie) - return DestroyWindowCookie{cookie} -} - -func (cook DestroyWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for DestroyWindow -func (c *Conn) destroyWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 4 // request opcode - b += 1 - - b += 1 // padding - - 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 DestroySubwindows -// size: 8 -type DestroySubwindowsCookie struct { - *cookie -} - -// Write request to wire for DestroySubwindows -func (c *Conn) DestroySubwindows(Window Window) DestroySubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.destroySubwindowsRequest(Window), cookie) - return DestroySubwindowsCookie{cookie} -} - -func (c *Conn) DestroySubwindowsChecked(Window Window) DestroySubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.destroySubwindowsRequest(Window), cookie) - return DestroySubwindowsCookie{cookie} -} - -func (cook DestroySubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for DestroySubwindows -func (c *Conn) destroySubwindowsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 5 // request opcode - b += 1 - - b += 1 // padding - - 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 ChangeSaveSet -// size: 8 -type ChangeSaveSetCookie struct { - *cookie -} - -// Write request to wire for ChangeSaveSet -func (c *Conn) ChangeSaveSet(Mode byte, Window Window) ChangeSaveSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeSaveSetRequest(Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} -} - -func (c *Conn) ChangeSaveSetChecked(Mode byte, Window Window) ChangeSaveSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeSaveSetRequest(Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} -} - -func (cook ChangeSaveSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeSaveSet -func (c *Conn) changeSaveSetRequest(Mode byte, Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 6 // request opcode - b += 1 - - buf[b] = Mode - 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 ReparentWindow -// size: 16 -type ReparentWindowCookie struct { - *cookie -} - -// Write request to wire for ReparentWindow -func (c *Conn) ReparentWindow(Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.reparentWindowRequest(Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} -} - -func (c *Conn) ReparentWindowChecked(Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.reparentWindowRequest(Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} -} - -func (cook ReparentWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for ReparentWindow -func (c *Conn) reparentWindowRequest(Window Window, Parent Window, X int16, Y int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 7 // request opcode - b += 1 - - b += 1 // padding - - 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(Parent)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - return buf -} - -// Request MapWindow -// size: 8 -type MapWindowCookie struct { - *cookie -} - -// Write request to wire for MapWindow -func (c *Conn) MapWindow(Window Window) MapWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.mapWindowRequest(Window), cookie) - return MapWindowCookie{cookie} -} - -func (c *Conn) MapWindowChecked(Window Window) MapWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.mapWindowRequest(Window), cookie) - return MapWindowCookie{cookie} -} - -func (cook MapWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for MapWindow -func (c *Conn) mapWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 8 // request opcode - b += 1 - - b += 1 // padding - - 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 MapSubwindows -// size: 8 -type MapSubwindowsCookie struct { - *cookie -} - -// Write request to wire for MapSubwindows -func (c *Conn) MapSubwindows(Window Window) MapSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.mapSubwindowsRequest(Window), cookie) - return MapSubwindowsCookie{cookie} -} - -func (c *Conn) MapSubwindowsChecked(Window Window) MapSubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.mapSubwindowsRequest(Window), cookie) - return MapSubwindowsCookie{cookie} -} - -func (cook MapSubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for MapSubwindows -func (c *Conn) mapSubwindowsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 9 // request opcode - b += 1 - - b += 1 // padding - - 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 UnmapWindow -// size: 8 -type UnmapWindowCookie struct { - *cookie -} - -// Write request to wire for UnmapWindow -func (c *Conn) UnmapWindow(Window Window) UnmapWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.unmapWindowRequest(Window), cookie) - return UnmapWindowCookie{cookie} -} - -func (c *Conn) UnmapWindowChecked(Window Window) UnmapWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.unmapWindowRequest(Window), cookie) - return UnmapWindowCookie{cookie} -} - -func (cook UnmapWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for UnmapWindow -func (c *Conn) unmapWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 10 // request opcode - b += 1 - - b += 1 // padding - - 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 UnmapSubwindows -// size: 8 -type UnmapSubwindowsCookie struct { - *cookie -} - -// Write request to wire for UnmapSubwindows -func (c *Conn) UnmapSubwindows(Window Window) UnmapSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.unmapSubwindowsRequest(Window), cookie) - return UnmapSubwindowsCookie{cookie} -} - -func (c *Conn) UnmapSubwindowsChecked(Window Window) UnmapSubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.unmapSubwindowsRequest(Window), cookie) - return UnmapSubwindowsCookie{cookie} -} - -func (cook UnmapSubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for UnmapSubwindows -func (c *Conn) unmapSubwindowsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 11 // request opcode - b += 1 - - b += 1 // padding - - 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 ConfigureWindow -// size: pad((10 + (2 + pad((4 * popCount(int(ValueMask))))))) -type ConfigureWindowCookie struct { - *cookie -} - -// Write request to wire for ConfigureWindow -func (c *Conn) ConfigureWindow(Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.configureWindowRequest(Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} -} - -func (c *Conn) ConfigureWindowChecked(Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.configureWindowRequest(Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} -} - -func (cook ConfigureWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for ConfigureWindow -func (c *Conn) configureWindowRequest(Window Window, ValueMask uint16, ValueList []uint32) []byte { - size := pad((10 + (2 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 12 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], ValueMask) - b += 2 - - b += 2 // padding - - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request CirculateWindow -// size: 8 -type CirculateWindowCookie struct { - *cookie -} - -// Write request to wire for CirculateWindow -func (c *Conn) CirculateWindow(Direction byte, Window Window) CirculateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.circulateWindowRequest(Direction, Window), cookie) - return CirculateWindowCookie{cookie} -} - -func (c *Conn) CirculateWindowChecked(Direction byte, Window Window) CirculateWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.circulateWindowRequest(Direction, Window), cookie) - return CirculateWindowCookie{cookie} -} - -func (cook CirculateWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CirculateWindow -func (c *Conn) circulateWindowRequest(Direction byte, Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 13 // request opcode - b += 1 - - buf[b] = Direction - 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 GetGeometry -// size: 8 -type GetGeometryCookie struct { - *cookie -} - -func (c *Conn) GetGeometry(Drawable Drawable) GetGeometryCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getGeometryRequest(Drawable), cookie) - return GetGeometryCookie{cookie} -} - -func (c *Conn) GetGeometryUnchecked(Drawable Drawable) GetGeometryCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getGeometryRequest(Drawable), cookie) - return GetGeometryCookie{cookie} -} - -// Request reply for GetGeometry -// size: 24 -type GetGeometryReply struct { - Sequence uint16 - Length uint32 - Depth byte - Root Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - // padding: 2 bytes -} - -// Waits and reads reply data from request GetGeometry -func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getGeometryReply(buf), nil -} - -// Read reply into structure from buffer for GetGeometry -func getGeometryReply(buf []byte) *GetGeometryReply { - v := new(GetGeometryReply) - 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.Root = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -func (cook GetGeometryCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetGeometry -func (c *Conn) getGeometryRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 14 // request opcode - b += 1 - - b += 1 // padding - - 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 QueryTree -// size: 8 -type QueryTreeCookie struct { - *cookie -} - -func (c *Conn) QueryTree(Window Window) QueryTreeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryTreeRequest(Window), cookie) - return QueryTreeCookie{cookie} -} - -func (c *Conn) QueryTreeUnchecked(Window Window) QueryTreeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryTreeRequest(Window), cookie) - return QueryTreeCookie{cookie} -} - -// Request reply for QueryTree -// size: (32 + pad((int(ChildrenLen) * 4))) -type QueryTreeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Root Window - Parent Window - ChildrenLen uint16 - // padding: 14 bytes - Children []Window // size: pad((int(ChildrenLen) * 4)) -} - -// Waits and reads reply data from request QueryTree -func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTreeReply(buf), nil -} - -// Read reply into structure from buffer for QueryTree -func queryTreeReply(buf []byte) *QueryTreeReply { - v := new(QueryTreeReply) - 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.Root = Window(Get32(buf[b:])) - b += 4 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.ChildrenLen = Get16(buf[b:]) - b += 2 - - b += 14 // padding - - v.Children = make([]Window, v.ChildrenLen) - for i := 0; i < int(v.ChildrenLen); i++ { - v.Children[i] = Window(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook QueryTreeCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryTree -func (c *Conn) queryTreeRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 15 // request opcode - b += 1 - - b += 1 // padding - - 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 InternAtom -// size: pad((8 + pad((int(NameLen) * 1)))) -type InternAtomCookie struct { - *cookie -} - -func (c *Conn) InternAtom(OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.internAtomRequest(OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} -} - -func (c *Conn) InternAtomUnchecked(OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.internAtomRequest(OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} -} - -// Request reply for InternAtom -// size: 12 -type InternAtomReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Atom Atom -} - -// Waits and reads reply data from request InternAtom -func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return internAtomReply(buf), nil -} - -// Read reply into structure from buffer for InternAtom -func internAtomReply(buf []byte) *InternAtomReply { - v := new(InternAtomReply) - 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.Atom = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook InternAtomCookie) Check() error { - return cook.check() -} - -// Write request to wire for InternAtom -func (c *Conn) internAtomRequest(OnlyIfExists bool, NameLen uint16, Name string) []byte { - size := pad((8 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 16 // request opcode - b += 1 - - if OnlyIfExists { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request GetAtomName -// size: 8 -type GetAtomNameCookie struct { - *cookie -} - -func (c *Conn) GetAtomName(Atom Atom) GetAtomNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getAtomNameRequest(Atom), cookie) - return GetAtomNameCookie{cookie} -} - -func (c *Conn) GetAtomNameUnchecked(Atom Atom) GetAtomNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getAtomNameRequest(Atom), cookie) - return GetAtomNameCookie{cookie} -} - -// Request reply for GetAtomName -// size: (32 + pad((int(NameLen) * 1))) -type GetAtomNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NameLen uint16 - // padding: 22 bytes - Name string // size: pad((int(NameLen) * 1)) -} - -// Waits and reads reply data from request GetAtomName -func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getAtomNameReply(buf), nil -} - -// Read reply into structure from buffer for GetAtomName -func getAtomNameReply(buf []byte) *GetAtomNameReply { - v := new(GetAtomNameReply) - 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.NameLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return v -} - -func (cook GetAtomNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetAtomName -func (c *Conn) getAtomNameRequest(Atom Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 17 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Atom)) - b += 4 - - return buf -} - -// Request ChangeProperty -// size: pad((24 + pad((((int(DataLen) * int(Format)) / 8) * 1)))) -type ChangePropertyCookie struct { - *cookie -} - -// Write request to wire for ChangeProperty -func (c *Conn) ChangeProperty(Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changePropertyRequest(Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} -} - -func (c *Conn) ChangePropertyChecked(Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changePropertyRequest(Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} -} - -func (cook ChangePropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeProperty -func (c *Conn) changePropertyRequest(Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { - size := pad((24 + pad((((int(DataLen) * int(Format)) / 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 18 // request opcode - b += 1 - - buf[b] = Mode - 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(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - buf[b] = Format - b += 1 - - b += 3 // padding - - Put32(buf[b:], DataLen) - b += 4 - - copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) - b += pad(int(((int(DataLen) * int(Format)) / 8))) - - return buf -} - -// Request DeleteProperty -// size: 12 -type DeletePropertyCookie struct { - *cookie -} - -// Write request to wire for DeleteProperty -func (c *Conn) DeleteProperty(Window Window, Property Atom) DeletePropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.deletePropertyRequest(Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -func (c *Conn) DeletePropertyChecked(Window Window, Property Atom) DeletePropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.deletePropertyRequest(Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -func (cook DeletePropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for DeleteProperty -func (c *Conn) deletePropertyRequest(Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 19 // request opcode - b += 1 - - b += 1 // padding - - 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(Property)) - b += 4 - - return buf -} - -// Request GetProperty -// size: 24 -type GetPropertyCookie struct { - *cookie -} - -func (c *Conn) GetProperty(Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getPropertyRequest(Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} -} - -func (c *Conn) GetPropertyUnchecked(Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getPropertyRequest(Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} -} - -// Request reply for GetProperty -// size: (32 + pad(((int(ValueLen) * (int(Format) / 8)) * 1))) -type GetPropertyReply struct { - Sequence uint16 - Length uint32 - Format byte - Type Atom - BytesAfter uint32 - ValueLen uint32 - // padding: 12 bytes - Value []byte // size: pad(((int(ValueLen) * (int(Format) / 8)) * 1)) -} - -// Waits and reads reply data from request GetProperty -func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPropertyReply(buf), nil -} - -// Read reply into structure from buffer for GetProperty -func getPropertyReply(buf []byte) *GetPropertyReply { - v := new(GetPropertyReply) - b := 1 // skip reply determinant - - v.Format = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Type = Atom(Get32(buf[b:])) - b += 4 - - v.BytesAfter = Get32(buf[b:]) - b += 4 - - v.ValueLen = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) - copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) - b += pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) - - return v -} - -func (cook GetPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetProperty -func (c *Conn) getPropertyRequest(Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 20 // request opcode - b += 1 - - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - 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(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - Put32(buf[b:], LongOffset) - b += 4 - - Put32(buf[b:], LongLength) - b += 4 - - return buf -} - -// Request ListProperties -// size: 8 -type ListPropertiesCookie struct { - *cookie -} - -func (c *Conn) ListProperties(Window Window) ListPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listPropertiesRequest(Window), cookie) - return ListPropertiesCookie{cookie} -} - -func (c *Conn) ListPropertiesUnchecked(Window Window) ListPropertiesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listPropertiesRequest(Window), cookie) - return ListPropertiesCookie{cookie} -} - -// Request reply for ListProperties -// size: (32 + pad((int(AtomsLen) * 4))) -type ListPropertiesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - AtomsLen uint16 - // padding: 22 bytes - Atoms []Atom // size: pad((int(AtomsLen) * 4)) -} - -// Waits and reads reply data from request ListProperties -func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listPropertiesReply(buf), nil -} - -// Read reply into structure from buffer for ListProperties -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) - 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.AtomsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Atoms = make([]Atom, v.AtomsLen) - for i := 0; i < int(v.AtomsLen); i++ { - v.Atoms[i] = Atom(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook ListPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListProperties -func (c *Conn) listPropertiesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 21 // request opcode - b += 1 - - b += 1 // padding - - 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 SetSelectionOwner -// size: 16 -type SetSelectionOwnerCookie struct { - *cookie -} - -// Write request to wire for SetSelectionOwner -func (c *Conn) SetSelectionOwner(Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setSelectionOwnerRequest(Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} -} - -func (c *Conn) SetSelectionOwnerChecked(Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setSelectionOwnerRequest(Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} -} - -func (cook SetSelectionOwnerCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetSelectionOwner -func (c *Conn) setSelectionOwnerRequest(Owner Window, Selection Atom, Time Timestamp) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 22 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Owner)) - b += 4 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GetSelectionOwner -// size: 8 -type GetSelectionOwnerCookie struct { - *cookie -} - -func (c *Conn) GetSelectionOwner(Selection Atom) GetSelectionOwnerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getSelectionOwnerRequest(Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -func (c *Conn) GetSelectionOwnerUnchecked(Selection Atom) GetSelectionOwnerCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getSelectionOwnerRequest(Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// Request reply for GetSelectionOwner -// size: 12 -type GetSelectionOwnerReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Owner Window -} - -// Waits and reads reply data from request GetSelectionOwner -func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionOwnerReply(buf), nil -} - -// Read reply into structure from buffer for GetSelectionOwner -func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { - v := new(GetSelectionOwnerReply) - 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.Owner = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GetSelectionOwnerCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetSelectionOwner -func (c *Conn) getSelectionOwnerRequest(Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 23 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// Request ConvertSelection -// size: 24 -type ConvertSelectionCookie struct { - *cookie -} - -// Write request to wire for ConvertSelection -func (c *Conn) ConvertSelection(Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.convertSelectionRequest(Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} -} - -func (c *Conn) ConvertSelectionChecked(Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.convertSelectionRequest(Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} -} - -func (cook ConvertSelectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for ConvertSelection -func (c *Conn) convertSelectionRequest(Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 24 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Requestor)) - b += 4 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - Put32(buf[b:], uint32(Target)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request SendEvent -// size: 44 -type SendEventCookie struct { - *cookie -} - -// Write request to wire for SendEvent -func (c *Conn) SendEvent(Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.sendEventRequest(Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} -} - -func (c *Conn) SendEventChecked(Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.sendEventRequest(Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} -} - -func (cook SendEventCookie) Check() error { - return cook.check() -} - -// Write request to wire for SendEvent -func (c *Conn) sendEventRequest(Propagate bool, Destination Window, EventMask uint32, Event string) []byte { - size := 44 - b := 0 - buf := make([]byte, size) - - buf[b] = 25 // request opcode - b += 1 - - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - - copy(buf[b:], Event[:32]) - b += pad(int(32)) - - return buf -} - -// Request GrabPointer -// size: 24 -type GrabPointerCookie struct { - *cookie -} - -func (c *Conn) GrabPointer(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.grabPointerRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} -} - -func (c *Conn) GrabPointerUnchecked(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.grabPointerRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} -} - -// Request reply for GrabPointer -// size: 8 -type GrabPointerReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request GrabPointer -func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return grabPointerReply(buf), nil -} - -// Read reply into structure from buffer for GrabPointer -func grabPointerReply(buf []byte) *GrabPointerReply { - v := new(GrabPointerReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook GrabPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabPointer -func (c *Conn) grabPointerRequest(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 26 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - Put32(buf[b:], uint32(ConfineTo)) - b += 4 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request UngrabPointer -// size: 8 -type UngrabPointerCookie struct { - *cookie -} - -// Write request to wire for UngrabPointer -func (c *Conn) UngrabPointer(Time Timestamp) UngrabPointerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabPointerRequest(Time), cookie) - return UngrabPointerCookie{cookie} -} - -func (c *Conn) UngrabPointerChecked(Time Timestamp) UngrabPointerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabPointerRequest(Time), cookie) - return UngrabPointerCookie{cookie} -} - -func (cook UngrabPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabPointer -func (c *Conn) ungrabPointerRequest(Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 27 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GrabButton -// size: 24 -type GrabButtonCookie struct { - *cookie -} - -// Write request to wire for GrabButton -func (c *Conn) GrabButton(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.grabButtonRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} -} - -func (c *Conn) GrabButtonChecked(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.grabButtonRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} -} - -func (cook GrabButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabButton -func (c *Conn) grabButtonRequest(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 28 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - Put32(buf[b:], uint32(ConfineTo)) - b += 4 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - buf[b] = Button - b += 1 - - b += 1 // padding - - Put16(buf[b:], Modifiers) - b += 2 - - return buf -} - -// Request UngrabButton -// size: 12 -type UngrabButtonCookie struct { - *cookie -} - -// Write request to wire for UngrabButton -func (c *Conn) UngrabButton(Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabButtonRequest(Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} -} - -func (c *Conn) UngrabButtonChecked(Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabButtonRequest(Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} -} - -func (cook UngrabButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabButton -func (c *Conn) ungrabButtonRequest(Button byte, GrabWindow Window, Modifiers uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 29 // request opcode - b += 1 - - buf[b] = Button - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// Request ChangeActivePointerGrab -// size: 16 -type ChangeActivePointerGrabCookie struct { - *cookie -} - -// Write request to wire for ChangeActivePointerGrab -func (c *Conn) ChangeActivePointerGrab(Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeActivePointerGrabRequest(Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} - -func (c *Conn) ChangeActivePointerGrabChecked(Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeActivePointerGrabRequest(Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} - -func (cook ChangeActivePointerGrabCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeActivePointerGrab -func (c *Conn) changeActivePointerGrabRequest(Cursor Cursor, Time Timestamp, EventMask uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 30 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - Put16(buf[b:], EventMask) - b += 2 - - b += 2 // padding - - return buf -} - -// Request GrabKeyboard -// size: 16 -type GrabKeyboardCookie struct { - *cookie -} - -func (c *Conn) GrabKeyboard(OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.grabKeyboardRequest(OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} -} - -func (c *Conn) GrabKeyboardUnchecked(OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.grabKeyboardRequest(OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} -} - -// Request reply for GrabKeyboard -// size: 8 -type GrabKeyboardReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request GrabKeyboard -func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return grabKeyboardReply(buf), nil -} - -// Read reply into structure from buffer for GrabKeyboard -func grabKeyboardReply(buf []byte) *GrabKeyboardReply { - v := new(GrabKeyboardReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook GrabKeyboardCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabKeyboard -func (c *Conn) grabKeyboardRequest(OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 31 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - b += 2 // padding - - return buf -} - -// Request UngrabKeyboard -// size: 8 -type UngrabKeyboardCookie struct { - *cookie -} - -// Write request to wire for UngrabKeyboard -func (c *Conn) UngrabKeyboard(Time Timestamp) UngrabKeyboardCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabKeyboardRequest(Time), cookie) - return UngrabKeyboardCookie{cookie} -} - -func (c *Conn) UngrabKeyboardChecked(Time Timestamp) UngrabKeyboardCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabKeyboardRequest(Time), cookie) - return UngrabKeyboardCookie{cookie} -} - -func (cook UngrabKeyboardCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabKeyboard -func (c *Conn) ungrabKeyboardRequest(Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 32 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GrabKey -// size: 16 -type GrabKeyCookie struct { - *cookie -} - -// Write request to wire for GrabKey -func (c *Conn) GrabKey(OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.grabKeyRequest(OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} -} - -func (c *Conn) GrabKeyChecked(OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.grabKeyRequest(OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} -} - -func (cook GrabKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabKey -func (c *Conn) grabKeyRequest(OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 33 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = byte(Key) - b += 1 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - b += 3 // padding - - return buf -} - -// Request UngrabKey -// size: 12 -type UngrabKeyCookie struct { - *cookie -} - -// Write request to wire for UngrabKey -func (c *Conn) UngrabKey(Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabKeyRequest(Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} -} - -func (c *Conn) UngrabKeyChecked(Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabKeyRequest(Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} -} - -func (cook UngrabKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabKey -func (c *Conn) ungrabKeyRequest(Key Keycode, GrabWindow Window, Modifiers uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 34 // request opcode - b += 1 - - buf[b] = byte(Key) - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// Request AllowEvents -// size: 8 -type AllowEventsCookie struct { - *cookie -} - -// Write request to wire for AllowEvents -func (c *Conn) AllowEvents(Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.allowEventsRequest(Mode, Time), cookie) - return AllowEventsCookie{cookie} -} - -func (c *Conn) AllowEventsChecked(Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.allowEventsRequest(Mode, Time), cookie) - return AllowEventsCookie{cookie} -} - -func (cook AllowEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllowEvents -func (c *Conn) allowEventsRequest(Mode byte, Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 35 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GrabServer -// size: 4 -type GrabServerCookie struct { - *cookie -} - -// Write request to wire for GrabServer -func (c *Conn) GrabServer() GrabServerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.grabServerRequest(), cookie) - return GrabServerCookie{cookie} -} - -func (c *Conn) GrabServerChecked() GrabServerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.grabServerRequest(), cookie) - return GrabServerCookie{cookie} -} - -func (cook GrabServerCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabServer -func (c *Conn) grabServerRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 36 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request UngrabServer -// size: 4 -type UngrabServerCookie struct { - *cookie -} - -// Write request to wire for UngrabServer -func (c *Conn) UngrabServer() UngrabServerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabServerRequest(), cookie) - return UngrabServerCookie{cookie} -} - -func (c *Conn) UngrabServerChecked() UngrabServerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabServerRequest(), cookie) - return UngrabServerCookie{cookie} -} - -func (cook UngrabServerCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabServer -func (c *Conn) ungrabServerRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 37 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request QueryPointer -// size: 8 -type QueryPointerCookie struct { - *cookie -} - -func (c *Conn) QueryPointer(Window Window) QueryPointerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryPointerRequest(Window), cookie) - return QueryPointerCookie{cookie} -} - -func (c *Conn) QueryPointerUnchecked(Window Window) QueryPointerCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryPointerRequest(Window), cookie) - return QueryPointerCookie{cookie} -} - -// Request reply for QueryPointer -// size: 28 -type QueryPointerReply struct { - Sequence uint16 - Length uint32 - SameScreen bool - Root Window - Child Window - RootX int16 - RootY int16 - WinX int16 - WinY int16 - Mask uint16 - // padding: 2 bytes -} - -// Waits and reads reply data from request QueryPointer -func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryPointerReply(buf), nil -} - -// Read reply into structure from buffer for QueryPointer -func queryPointerReply(buf []byte) *QueryPointerReply { - v := new(QueryPointerReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.WinX = int16(Get16(buf[b:])) - b += 2 - - v.WinY = int16(Get16(buf[b:])) - b += 2 - - v.Mask = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -func (cook QueryPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryPointer -func (c *Conn) queryPointerRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 38 // request opcode - b += 1 - - b += 1 // padding - - 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 GetMotionEvents -// size: 16 -type GetMotionEventsCookie struct { - *cookie -} - -func (c *Conn) GetMotionEvents(Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getMotionEventsRequest(Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} -} - -func (c *Conn) GetMotionEventsUnchecked(Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getMotionEventsRequest(Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} -} - -// Request reply for GetMotionEvents -// size: (32 + pad((int(EventsLen) * 8))) -type GetMotionEventsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - EventsLen uint32 - // padding: 20 bytes - Events []Timecoord // size: pad((int(EventsLen) * 8)) -} - -// Waits and reads reply data from request GetMotionEvents -func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMotionEventsReply(buf), nil -} - -// Read reply into structure from buffer for GetMotionEvents -func getMotionEventsReply(buf []byte) *GetMotionEventsReply { - v := new(GetMotionEventsReply) - 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.EventsLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Events = make([]Timecoord, v.EventsLen) - b += ReadTimecoordList(buf[b:], v.Events) - - return v -} - -func (cook GetMotionEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetMotionEvents -func (c *Conn) getMotionEventsRequest(Window Window, Start Timestamp, Stop Timestamp) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 39 // request opcode - b += 1 - - b += 1 // padding - - 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(Start)) - b += 4 - - Put32(buf[b:], uint32(Stop)) - b += 4 - - return buf -} - -// Request TranslateCoordinates -// size: 16 -type TranslateCoordinatesCookie struct { - *cookie -} - -func (c *Conn) TranslateCoordinates(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.translateCoordinatesRequest(SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} -} - -func (c *Conn) TranslateCoordinatesUnchecked(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.translateCoordinatesRequest(SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} -} - -// Request reply for TranslateCoordinates -// size: 16 -type TranslateCoordinatesReply struct { - Sequence uint16 - Length uint32 - SameScreen bool - Child Window - DstX int16 - DstY int16 -} - -// Waits and reads reply data from request TranslateCoordinates -func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return translateCoordinatesReply(buf), nil -} - -// Read reply into structure from buffer for TranslateCoordinates -func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { - v := new(TranslateCoordinatesReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.DstX = int16(Get16(buf[b:])) - b += 2 - - v.DstY = int16(Get16(buf[b:])) - b += 2 - - return v -} - -func (cook TranslateCoordinatesCookie) Check() error { - return cook.check() -} - -// Write request to wire for TranslateCoordinates -func (c *Conn) translateCoordinatesRequest(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 40 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - Put32(buf[b:], uint32(DstWindow)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - return buf -} - -// Request WarpPointer -// size: 24 -type WarpPointerCookie struct { - *cookie -} - -// Write request to wire for WarpPointer -func (c *Conn) WarpPointer(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.warpPointerRequest(SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} -} - -func (c *Conn) WarpPointerChecked(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.warpPointerRequest(SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} -} - -func (cook WarpPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for WarpPointer -func (c *Conn) warpPointerRequest(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 41 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - Put32(buf[b:], uint32(DstWindow)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(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 - - return buf -} - -// Request SetInputFocus -// size: 12 -type SetInputFocusCookie struct { - *cookie -} - -// Write request to wire for SetInputFocus -func (c *Conn) SetInputFocus(RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setInputFocusRequest(RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} -} - -func (c *Conn) SetInputFocusChecked(RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setInputFocusRequest(RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} -} - -func (cook SetInputFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetInputFocus -func (c *Conn) setInputFocusRequest(RevertTo byte, Focus Window, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 42 // request opcode - b += 1 - - buf[b] = RevertTo - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Focus)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GetInputFocus -// size: 4 -type GetInputFocusCookie struct { - *cookie -} - -func (c *Conn) GetInputFocus() GetInputFocusCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getInputFocusRequest(), cookie) - return GetInputFocusCookie{cookie} -} - -func (c *Conn) GetInputFocusUnchecked() GetInputFocusCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getInputFocusRequest(), cookie) - return GetInputFocusCookie{cookie} -} - -// Request reply for GetInputFocus -// size: 12 -type GetInputFocusReply struct { - Sequence uint16 - Length uint32 - RevertTo byte - Focus Window -} - -// Waits and reads reply data from request GetInputFocus -func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getInputFocusReply(buf), nil -} - -// Read reply into structure from buffer for GetInputFocus -func getInputFocusReply(buf []byte) *GetInputFocusReply { - v := new(GetInputFocusReply) - b := 1 // skip reply determinant - - v.RevertTo = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Focus = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GetInputFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetInputFocus -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 -} - -// Request QueryKeymap -// size: 4 -type QueryKeymapCookie struct { - *cookie -} - -func (c *Conn) QueryKeymap() QueryKeymapCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryKeymapRequest(), cookie) - return QueryKeymapCookie{cookie} -} - -func (c *Conn) QueryKeymapUnchecked() QueryKeymapCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryKeymapRequest(), cookie) - return QueryKeymapCookie{cookie} -} - -// Request reply for QueryKeymap -// size: 40 -type QueryKeymapReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Keys []byte // size: 32 -} - -// Waits and reads reply data from request QueryKeymap -func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryKeymapReply(buf), nil -} - -// Read reply into structure from buffer for QueryKeymap -func queryKeymapReply(buf []byte) *QueryKeymapReply { - v := new(QueryKeymapReply) - 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.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += pad(int(32)) - - return v -} - -func (cook QueryKeymapCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryKeymap -func (c *Conn) queryKeymapRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 44 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request OpenFont -// size: pad((12 + pad((int(NameLen) * 1)))) -type OpenFontCookie struct { - *cookie -} - -// Write request to wire for OpenFont -func (c *Conn) OpenFont(Fid Font, NameLen uint16, Name string) OpenFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.openFontRequest(Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} -} - -func (c *Conn) OpenFontChecked(Fid Font, NameLen uint16, Name string) OpenFontCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.openFontRequest(Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} -} - -func (cook OpenFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for OpenFont -func (c *Conn) openFontRequest(Fid Font, NameLen uint16, Name string) []byte { - size := pad((12 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 45 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fid)) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request CloseFont -// size: 8 -type CloseFontCookie struct { - *cookie -} - -// Write request to wire for CloseFont -func (c *Conn) CloseFont(Font Font) CloseFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.closeFontRequest(Font), cookie) - return CloseFontCookie{cookie} -} - -func (c *Conn) CloseFontChecked(Font Font) CloseFontCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.closeFontRequest(Font), cookie) - return CloseFontCookie{cookie} -} - -func (cook CloseFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for CloseFont -func (c *Conn) closeFontRequest(Font Font) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 46 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Font)) - b += 4 - - return buf -} - -// Request QueryFont -// size: 8 -type QueryFontCookie struct { - *cookie -} - -func (c *Conn) QueryFont(Font Fontable) QueryFontCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryFontRequest(Font), cookie) - return QueryFontCookie{cookie} -} - -func (c *Conn) QueryFontUnchecked(Font Fontable) QueryFontCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryFontRequest(Font), cookie) - return QueryFontCookie{cookie} -} - -// Request reply for QueryFont -// size: ((60 + pad((int(PropertiesLen) * 8))) + pad((int(CharInfosLen) * 12))) -type QueryFontReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - CharInfosLen uint32 - Properties []Fontprop // size: pad((int(PropertiesLen) * 8)) - CharInfos []Charinfo // size: pad((int(CharInfosLen) * 12)) -} - -// Waits and reads reply data from request QueryFont -func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryFontReply(buf), nil -} - -// Read reply into structure from buffer for QueryFont -func queryFontReply(buf []byte) *QueryFontReply { - v := new(QueryFontReply) - 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.MinBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MaxBounds) - - b += 4 // padding - - v.MinCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.MaxCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.DefaultChar = Get16(buf[b:]) - b += 2 - - v.PropertiesLen = Get16(buf[b:]) - b += 2 - - v.DrawDirection = buf[b] - b += 1 - - v.MinByte1 = buf[b] - b += 1 - - v.MaxByte1 = buf[b] - b += 1 - - if buf[b] == 1 { - v.AllCharsExist = true - } else { - v.AllCharsExist = false - } - b += 1 - - v.FontAscent = int16(Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(Get16(buf[b:])) - b += 2 - - v.CharInfosLen = Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += ReadFontpropList(buf[b:], v.Properties) - - v.CharInfos = make([]Charinfo, v.CharInfosLen) - b += ReadCharinfoList(buf[b:], v.CharInfos) - - return v -} - -func (cook QueryFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryFont -func (c *Conn) queryFontRequest(Font Fontable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 47 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Font)) - b += 4 - - return buf -} - -// Request QueryTextExtents -// size: pad((8 + pad((len(String) * 2)))) -type QueryTextExtentsCookie struct { - *cookie -} - -func (c *Conn) QueryTextExtents(Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryTextExtentsRequest(Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} -} - -func (c *Conn) QueryTextExtentsUnchecked(Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryTextExtentsRequest(Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} -} - -// Request reply for QueryTextExtents -// size: 28 -type QueryTextExtentsReply struct { - Sequence uint16 - Length uint32 - DrawDirection byte - FontAscent int16 - FontDescent int16 - OverallAscent int16 - OverallDescent int16 - OverallWidth int32 - OverallLeft int32 - OverallRight int32 -} - -// Waits and reads reply data from request QueryTextExtents -func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTextExtentsReply(buf), nil -} - -// Read reply into structure from buffer for QueryTextExtents -func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { - v := new(QueryTextExtentsReply) - b := 1 // skip reply determinant - - v.DrawDirection = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.FontAscent = int16(Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(Get16(buf[b:])) - b += 2 - - v.OverallAscent = int16(Get16(buf[b:])) - b += 2 - - v.OverallDescent = int16(Get16(buf[b:])) - b += 2 - - v.OverallWidth = int32(Get32(buf[b:])) - b += 4 - - v.OverallLeft = int32(Get32(buf[b:])) - b += 4 - - v.OverallRight = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook QueryTextExtentsCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryTextExtents -func (c *Conn) queryTextExtentsRequest(Font Fontable, String []Char2b, StringLen uint16) []byte { - size := pad((8 + pad((len(String) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 48 // request opcode - b += 1 - - buf[b] = byte((int(StringLen) & 1)) - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Font)) - b += 4 - - b += Char2bListBytes(buf[b:], String) - - // skip writing local field: StringLen (2) :: uint16 - - return buf -} - -// Request ListFonts -// size: pad((8 + pad((int(PatternLen) * 1)))) -type ListFontsCookie struct { - *cookie -} - -func (c *Conn) ListFonts(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listFontsRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -func (c *Conn) ListFontsUnchecked(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listFontsRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -// Request reply for ListFonts -// size: (32 + StrListSize(Names)) -type ListFontsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NamesLen uint16 - // padding: 22 bytes - Names []Str // size: StrListSize(Names) -} - -// Waits and reads reply data from request ListFonts -func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listFontsReply(buf), nil -} - -// Read reply into structure from buffer for ListFonts -func listFontsReply(buf []byte) *ListFontsReply { - v := new(ListFontsReply) - 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.NamesLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Names = make([]Str, v.NamesLen) - b += ReadStrList(buf[b:], v.Names) - - return v -} - -func (cook ListFontsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListFonts -func (c *Conn) listFontsRequest(MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := pad((8 + pad((int(PatternLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 49 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], MaxNames) - b += 2 - - Put16(buf[b:], PatternLen) - b += 2 - - copy(buf[b:], Pattern[:PatternLen]) - b += pad(int(PatternLen)) - - return buf -} - -// Request ListFontsWithInfo -// size: pad((8 + pad((int(PatternLen) * 1)))) -type ListFontsWithInfoCookie struct { - *cookie -} - -func (c *Conn) ListFontsWithInfo(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listFontsWithInfoRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} -} - -func (c *Conn) ListFontsWithInfoUnchecked(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listFontsWithInfoRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} -} - -// Request reply for ListFontsWithInfo -// size: ((60 + pad((int(PropertiesLen) * 8))) + pad((int(NameLen) * 1))) -type ListFontsWithInfoReply struct { - Sequence uint16 - Length uint32 - NameLen byte - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - RepliesHint uint32 - Properties []Fontprop // size: pad((int(PropertiesLen) * 8)) - Name string // size: pad((int(NameLen) * 1)) -} - -// Waits and reads reply data from request ListFontsWithInfo -func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listFontsWithInfoReply(buf), nil -} - -// Read reply into structure from buffer for ListFontsWithInfo -func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { - v := new(ListFontsWithInfoReply) - b := 1 // skip reply determinant - - v.NameLen = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MaxBounds) - - b += 4 // padding - - v.MinCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.MaxCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.DefaultChar = Get16(buf[b:]) - b += 2 - - v.PropertiesLen = Get16(buf[b:]) - b += 2 - - v.DrawDirection = buf[b] - b += 1 - - v.MinByte1 = buf[b] - b += 1 - - v.MaxByte1 = buf[b] - b += 1 - - if buf[b] == 1 { - v.AllCharsExist = true - } else { - v.AllCharsExist = false - } - b += 1 - - v.FontAscent = int16(Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(Get16(buf[b:])) - b += 2 - - v.RepliesHint = Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += ReadFontpropList(buf[b:], v.Properties) - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return v -} - -func (cook ListFontsWithInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListFontsWithInfo -func (c *Conn) listFontsWithInfoRequest(MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := pad((8 + pad((int(PatternLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 50 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], MaxNames) - b += 2 - - Put16(buf[b:], PatternLen) - b += 2 - - copy(buf[b:], Pattern[:PatternLen]) - b += pad(int(PatternLen)) - - return buf -} - -// Request SetFontPath -// size: pad((8 + StrListSize(Font))) -type SetFontPathCookie struct { - *cookie -} - -// Write request to wire for SetFontPath -func (c *Conn) SetFontPath(FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setFontPathRequest(FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -func (c *Conn) SetFontPathChecked(FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setFontPathRequest(FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -func (cook SetFontPathCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetFontPath -func (c *Conn) setFontPathRequest(FontQty uint16, Font []Str) []byte { - size := pad((8 + StrListSize(Font))) - b := 0 - buf := make([]byte, size) - - buf[b] = 51 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], FontQty) - b += 2 - - b += 2 // padding - - b += StrListBytes(buf[b:], Font) - - return buf -} - -// Request GetFontPath -// size: 4 -type GetFontPathCookie struct { - *cookie -} - -func (c *Conn) GetFontPath() GetFontPathCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getFontPathRequest(), cookie) - return GetFontPathCookie{cookie} -} - -func (c *Conn) GetFontPathUnchecked() GetFontPathCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getFontPathRequest(), cookie) - return GetFontPathCookie{cookie} -} - -// Request reply for GetFontPath -// size: (32 + StrListSize(Path)) -type GetFontPathReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PathLen uint16 - // padding: 22 bytes - Path []Str // size: StrListSize(Path) -} - -// Waits and reads reply data from request GetFontPath -func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getFontPathReply(buf), nil -} - -// Read reply into structure from buffer for GetFontPath -func getFontPathReply(buf []byte) *GetFontPathReply { - v := new(GetFontPathReply) - 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.PathLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Path = make([]Str, v.PathLen) - b += ReadStrList(buf[b:], v.Path) - - return v -} - -func (cook GetFontPathCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetFontPath -func (c *Conn) getFontPathRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 52 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request CreatePixmap -// size: 16 -type CreatePixmapCookie struct { - *cookie -} - -// Write request to wire for CreatePixmap -func (c *Conn) CreatePixmap(Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createPixmapRequest(Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -func (c *Conn) CreatePixmapChecked(Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createPixmapRequest(Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -func (cook CreatePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreatePixmap -func (c *Conn) createPixmapRequest(Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 53 // request opcode - b += 1 - - buf[b] = Depth - 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 - - return buf -} - -// Request FreePixmap -// size: 8 -type FreePixmapCookie struct { - *cookie -} - -// Write request to wire for FreePixmap -func (c *Conn) FreePixmap(Pixmap Pixmap) FreePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freePixmapRequest(Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -func (c *Conn) FreePixmapChecked(Pixmap Pixmap) FreePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freePixmapRequest(Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -func (cook FreePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreePixmap -func (c *Conn) freePixmapRequest(Pixmap Pixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 54 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - return buf -} - -// Request CreateGC -// size: pad((12 + (4 + pad((4 * popCount(int(ValueMask))))))) -type CreateGCCookie struct { - *cookie -} - -// Write request to wire for CreateGC -func (c *Conn) CreateGC(Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createGCRequest(Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -func (c *Conn) CreateGCChecked(Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createGCRequest(Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -func (cook CreateGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateGC -func (c *Conn) createGCRequest(Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { - size := pad((12 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 55 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - 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 ChangeGC -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ChangeGCCookie struct { - *cookie -} - -// Write request to wire for ChangeGC -func (c *Conn) ChangeGC(Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeGCRequest(Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -func (c *Conn) ChangeGCChecked(Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeGCRequest(Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -func (cook ChangeGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeGC -func (c *Conn) changeGCRequest(Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 56 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - 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 CopyGC -// size: 16 -type CopyGCCookie struct { - *cookie -} - -// Write request to wire for CopyGC -func (c *Conn) CopyGC(SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyGCRequest(SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -func (c *Conn) CopyGCChecked(SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyGCRequest(SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -func (cook CopyGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyGC -func (c *Conn) copyGCRequest(SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 57 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcGc)) - b += 4 - - Put32(buf[b:], uint32(DstGc)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - - return buf -} - -// Request SetDashes -// size: pad((12 + pad((int(DashesLen) * 1)))) -type SetDashesCookie struct { - *cookie -} - -// Write request to wire for SetDashes -func (c *Conn) SetDashes(Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setDashesRequest(Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} -} - -func (c *Conn) SetDashesChecked(Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setDashesRequest(Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} -} - -func (cook SetDashesCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetDashes -func (c *Conn) setDashesRequest(Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { - size := pad((12 + pad((int(DashesLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 58 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], DashOffset) - b += 2 - - Put16(buf[b:], DashesLen) - b += 2 - - copy(buf[b:], Dashes[:DashesLen]) - b += pad(int(DashesLen)) - - return buf -} - -// Request SetClipRectangles -// size: pad((12 + pad((len(Rectangles) * 8)))) -type SetClipRectanglesCookie struct { - *cookie -} - -// Write request to wire for SetClipRectangles -func (c *Conn) SetClipRectangles(Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setClipRectanglesRequest(Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -func (c *Conn) SetClipRectanglesChecked(Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setClipRectanglesRequest(Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -func (cook SetClipRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetClipRectangles -func (c *Conn) setClipRectanglesRequest(Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 59 // request opcode - b += 1 - - buf[b] = Ordering - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request FreeGC -// size: 8 -type FreeGCCookie struct { - *cookie -} - -// Write request to wire for FreeGC -func (c *Conn) FreeGC(Gc Gcontext) FreeGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeGCRequest(Gc), cookie) - return FreeGCCookie{cookie} -} - -func (c *Conn) FreeGCChecked(Gc Gcontext) FreeGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeGCRequest(Gc), cookie) - return FreeGCCookie{cookie} -} - -func (cook FreeGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeGC -func (c *Conn) freeGCRequest(Gc Gcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 60 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - return buf -} - -// Request ClearArea -// size: 16 -type ClearAreaCookie struct { - *cookie -} - -// Write request to wire for ClearArea -func (c *Conn) ClearArea(Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.clearAreaRequest(Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -func (c *Conn) ClearAreaChecked(Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.clearAreaRequest(Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -func (cook ClearAreaCookie) Check() error { - return cook.check() -} - -// Write request to wire for ClearArea -func (c *Conn) clearAreaRequest(Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 61 // request opcode - b += 1 - - if Exposures { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - 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 - - return buf -} - -// Request CopyArea -// size: 28 -type CopyAreaCookie struct { - *cookie -} - -// Write request to wire for CopyArea -func (c *Conn) CopyArea(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyAreaRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} -} - -func (c *Conn) CopyAreaChecked(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyAreaRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} -} - -func (cook CopyAreaCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyArea -func (c *Conn) copyAreaRequest(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = 62 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request CopyPlane -// size: 32 -type CopyPlaneCookie struct { - *cookie -} - -// Write request to wire for CopyPlane -func (c *Conn) CopyPlane(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyPlaneRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -func (c *Conn) CopyPlaneChecked(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyPlaneRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -func (cook CopyPlaneCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyPlane -func (c *Conn) copyPlaneRequest(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 63 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], BitPlane) - b += 4 - - return buf -} - -// Request PolyPoint -// size: pad((12 + pad((len(Points) * 4)))) -type PolyPointCookie struct { - *cookie -} - -// Write request to wire for PolyPoint -func (c *Conn) PolyPoint(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyPointRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} - -func (c *Conn) PolyPointChecked(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyPointRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} - -func (cook PolyPointCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyPoint -func (c *Conn) polyPointRequest(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := pad((12 + pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 64 // request opcode - b += 1 - - buf[b] = CoordinateMode - 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 - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// Request PolyLine -// size: pad((12 + pad((len(Points) * 4)))) -type PolyLineCookie struct { - *cookie -} - -// Write request to wire for PolyLine -func (c *Conn) PolyLine(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyLineRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} -} - -func (c *Conn) PolyLineChecked(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyLineRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} -} - -func (cook PolyLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyLine -func (c *Conn) polyLineRequest(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := pad((12 + pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 65 // request opcode - b += 1 - - buf[b] = CoordinateMode - 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 - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// Request PolySegment -// size: pad((12 + pad((len(Segments) * 8)))) -type PolySegmentCookie struct { - *cookie -} - -// Write request to wire for PolySegment -func (c *Conn) PolySegment(Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polySegmentRequest(Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} -} - -func (c *Conn) PolySegmentChecked(Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polySegmentRequest(Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} -} - -func (cook PolySegmentCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolySegment -func (c *Conn) polySegmentRequest(Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { - size := pad((12 + pad((len(Segments) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 66 // request opcode - b += 1 - - b += 1 // padding - - 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 - - b += SegmentListBytes(buf[b:], Segments) - - return buf -} - -// Request PolyRectangle -// size: pad((12 + pad((len(Rectangles) * 8)))) -type PolyRectangleCookie struct { - *cookie -} - -// Write request to wire for PolyRectangle -func (c *Conn) PolyRectangle(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} - -func (c *Conn) PolyRectangleChecked(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} - -func (cook PolyRectangleCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyRectangle -func (c *Conn) polyRectangleRequest(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 67 // request opcode - b += 1 - - b += 1 // padding - - 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 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request PolyArc -// size: pad((12 + pad((len(Arcs) * 12)))) -type PolyArcCookie struct { - *cookie -} - -// Write request to wire for PolyArc -func (c *Conn) PolyArc(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyArcRequest(Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} -} - -func (c *Conn) PolyArcChecked(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyArcRequest(Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} -} - -func (cook PolyArcCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyArc -func (c *Conn) polyArcRequest(Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := pad((12 + pad((len(Arcs) * 12)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 68 // request opcode - b += 1 - - b += 1 // padding - - 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 - - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// Request FillPoly -// size: pad((16 + pad((len(Points) * 4)))) -type FillPolyCookie struct { - *cookie -} - -// Write request to wire for FillPoly -func (c *Conn) FillPoly(Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.fillPolyRequest(Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} - -func (c *Conn) FillPolyChecked(Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.fillPolyRequest(Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} - -func (cook FillPolyCookie) Check() error { - return cook.check() -} - -// Write request to wire for FillPoly -func (c *Conn) fillPolyRequest(Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { - size := pad((16 + pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 69 // request opcode - b += 1 - - b += 1 // padding - - 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 - - buf[b] = Shape - b += 1 - - buf[b] = CoordinateMode - b += 1 - - b += 2 // padding - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// Request PolyFillRectangle -// size: pad((12 + pad((len(Rectangles) * 8)))) -type PolyFillRectangleCookie struct { - *cookie -} - -// Write request to wire for PolyFillRectangle -func (c *Conn) PolyFillRectangle(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyFillRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} -} - -func (c *Conn) PolyFillRectangleChecked(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyFillRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} -} - -func (cook PolyFillRectangleCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyFillRectangle -func (c *Conn) polyFillRectangleRequest(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 70 // request opcode - b += 1 - - b += 1 // padding - - 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 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request PolyFillArc -// size: pad((12 + pad((len(Arcs) * 12)))) -type PolyFillArcCookie struct { - *cookie -} - -// Write request to wire for PolyFillArc -func (c *Conn) PolyFillArc(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyFillArcRequest(Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} - -func (c *Conn) PolyFillArcChecked(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyFillArcRequest(Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} - -func (cook PolyFillArcCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyFillArc -func (c *Conn) polyFillArcRequest(Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := pad((12 + pad((len(Arcs) * 12)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 71 // request opcode - b += 1 - - b += 1 // padding - - 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 - - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// Request PutImage -// size: pad((24 + pad((len(Data) * 1)))) -type PutImageCookie struct { - *cookie -} - -// Write request to wire for PutImage -func (c *Conn) PutImage(Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.putImageRequest(Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} -} - -func (c *Conn) PutImageChecked(Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.putImageRequest(Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} -} - -func (cook PutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for PutImage -func (c *Conn) putImageRequest(Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { - size := pad((24 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 72 // request opcode - b += 1 - - buf[b] = Format - 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:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = LeftPad - b += 1 - - buf[b] = Depth - b += 1 - - b += 2 // padding - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GetImage -// size: 20 -type GetImageCookie struct { - *cookie -} - -func (c *Conn) GetImage(Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getImageRequest(Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -func (c *Conn) GetImageUnchecked(Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getImageRequest(Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -// Request reply for GetImage -// size: (32 + pad(((int(Length) * 4) * 1))) -type GetImageReply struct { - Sequence uint16 - Length uint32 - Depth byte - Visual Visualid - // padding: 20 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GetImage -func (cook GetImageCookie) Reply() (*GetImageReply, error) { - buf, err := cook.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 = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GetImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetImage -func (c *Conn) getImageRequest(Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = 73 // request opcode - b += 1 - - buf[b] = Format - 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 - - return buf -} - -// Request PolyText8 -// size: pad((16 + pad((len(Items) * 1)))) -type PolyText8Cookie struct { - *cookie -} - -// Write request to wire for PolyText8 -func (c *Conn) PolyText8(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyText8Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} -} - -func (c *Conn) PolyText8Checked(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyText8Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} -} - -func (cook PolyText8Cookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyText8 -func (c *Conn) polyText8Request(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := pad((16 + pad((len(Items) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 74 // request opcode - b += 1 - - b += 1 // padding - - 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:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], Items[:len(Items)]) - b += pad(int(len(Items))) - - return buf -} - -// Request PolyText16 -// size: pad((16 + pad((len(Items) * 1)))) -type PolyText16Cookie struct { - *cookie -} - -// Write request to wire for PolyText16 -func (c *Conn) PolyText16(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyText16Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} -} - -func (c *Conn) PolyText16Checked(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyText16Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} -} - -func (cook PolyText16Cookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyText16 -func (c *Conn) polyText16Request(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := pad((16 + pad((len(Items) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 75 // request opcode - b += 1 - - b += 1 // padding - - 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:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], Items[:len(Items)]) - b += pad(int(len(Items))) - - return buf -} - -// Request ImageText8 -// size: pad((16 + pad((int(StringLen) * 1)))) -type ImageText8Cookie struct { - *cookie -} - -// Write request to wire for ImageText8 -func (c *Conn) ImageText8(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.imageText8Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} -} - -func (c *Conn) ImageText8Checked(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.imageText8Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} -} - -func (cook ImageText8Cookie) Check() error { - return cook.check() -} - -// Write request to wire for ImageText8 -func (c *Conn) imageText8Request(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { - size := pad((16 + pad((int(StringLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 76 // request opcode - b += 1 - - buf[b] = StringLen - 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:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], String[:StringLen]) - b += pad(int(StringLen)) - - return buf -} - -// Request ImageText16 -// size: pad((16 + pad((int(StringLen) * 2)))) -type ImageText16Cookie struct { - *cookie -} - -// Write request to wire for ImageText16 -func (c *Conn) ImageText16(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.imageText16Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} -} - -func (c *Conn) ImageText16Checked(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.imageText16Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} -} - -func (cook ImageText16Cookie) Check() error { - return cook.check() -} - -// Write request to wire for ImageText16 -func (c *Conn) imageText16Request(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { - size := pad((16 + pad((int(StringLen) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 77 // request opcode - b += 1 - - buf[b] = StringLen - 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:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - b += Char2bListBytes(buf[b:], String) - - return buf -} - -// Request CreateColormap -// size: 16 -type CreateColormapCookie struct { - *cookie -} - -// Write request to wire for CreateColormap -func (c *Conn) CreateColormap(Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createColormapRequest(Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -func (c *Conn) CreateColormapChecked(Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createColormapRequest(Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -func (cook CreateColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateColormap -func (c *Conn) createColormapRequest(Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 78 // request opcode - b += 1 - - buf[b] = Alloc - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Mid)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - return buf -} - -// Request FreeColormap -// size: 8 -type FreeColormapCookie struct { - *cookie -} - -// Write request to wire for FreeColormap -func (c *Conn) FreeColormap(Cmap Colormap) FreeColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeColormapRequest(Cmap), cookie) - return FreeColormapCookie{cookie} -} - -func (c *Conn) FreeColormapChecked(Cmap Colormap) FreeColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeColormapRequest(Cmap), cookie) - return FreeColormapCookie{cookie} -} - -func (cook FreeColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeColormap -func (c *Conn) freeColormapRequest(Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 79 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// Request CopyColormapAndFree -// size: 12 -type CopyColormapAndFreeCookie struct { - *cookie -} - -// Write request to wire for CopyColormapAndFree -func (c *Conn) CopyColormapAndFree(Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyColormapAndFreeRequest(Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -func (c *Conn) CopyColormapAndFreeChecked(Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyColormapAndFreeRequest(Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -func (cook CopyColormapAndFreeCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyColormapAndFree -func (c *Conn) copyColormapAndFreeRequest(Mid Colormap, SrcCmap Colormap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 80 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Mid)) - b += 4 - - Put32(buf[b:], uint32(SrcCmap)) - b += 4 - - return buf -} - -// Request InstallColormap -// size: 8 -type InstallColormapCookie struct { - *cookie -} - -// Write request to wire for InstallColormap -func (c *Conn) InstallColormap(Cmap Colormap) InstallColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.installColormapRequest(Cmap), cookie) - return InstallColormapCookie{cookie} -} - -func (c *Conn) InstallColormapChecked(Cmap Colormap) InstallColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.installColormapRequest(Cmap), cookie) - return InstallColormapCookie{cookie} -} - -func (cook InstallColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for InstallColormap -func (c *Conn) installColormapRequest(Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 81 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// Request UninstallColormap -// size: 8 -type UninstallColormapCookie struct { - *cookie -} - -// Write request to wire for UninstallColormap -func (c *Conn) UninstallColormap(Cmap Colormap) UninstallColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.uninstallColormapRequest(Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -func (c *Conn) UninstallColormapChecked(Cmap Colormap) UninstallColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.uninstallColormapRequest(Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -func (cook UninstallColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for UninstallColormap -func (c *Conn) uninstallColormapRequest(Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 82 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// Request ListInstalledColormaps -// size: 8 -type ListInstalledColormapsCookie struct { - *cookie -} - -func (c *Conn) ListInstalledColormaps(Window Window) ListInstalledColormapsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listInstalledColormapsRequest(Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -func (c *Conn) ListInstalledColormapsUnchecked(Window Window) ListInstalledColormapsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listInstalledColormapsRequest(Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -// Request reply for ListInstalledColormaps -// size: (32 + pad((int(CmapsLen) * 4))) -type ListInstalledColormapsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - CmapsLen uint16 - // padding: 22 bytes - Cmaps []Colormap // size: pad((int(CmapsLen) * 4)) -} - -// Waits and reads reply data from request ListInstalledColormaps -func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listInstalledColormapsReply(buf), nil -} - -// Read reply into structure from buffer for ListInstalledColormaps -func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { - v := new(ListInstalledColormapsReply) - 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.CmapsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Cmaps = make([]Colormap, v.CmapsLen) - for i := 0; i < int(v.CmapsLen); i++ { - v.Cmaps[i] = Colormap(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook ListInstalledColormapsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListInstalledColormaps -func (c *Conn) listInstalledColormapsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 83 // request opcode - b += 1 - - b += 1 // padding - - 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 AllocColor -// size: 16 -type AllocColorCookie struct { - *cookie -} - -func (c *Conn) AllocColor(Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocColorRequest(Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} -} - -func (c *Conn) AllocColorUnchecked(Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocColorRequest(Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} -} - -// Request reply for AllocColor -// size: 20 -type AllocColorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes - Pixel uint32 -} - -// Waits and reads reply data from request AllocColor -func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorReply(buf), nil -} - -// Read reply into structure from buffer for AllocColor -func allocColorReply(buf []byte) *AllocColorReply { - v := new(AllocColorReply) - 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.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Pixel = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook AllocColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocColor -func (c *Conn) allocColorRequest(Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 84 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], Red) - b += 2 - - Put16(buf[b:], Green) - b += 2 - - Put16(buf[b:], Blue) - b += 2 - - b += 2 // padding - - return buf -} - -// Request AllocNamedColor -// size: pad((12 + pad((int(NameLen) * 1)))) -type AllocNamedColorCookie struct { - *cookie -} - -func (c *Conn) AllocNamedColor(Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocNamedColorRequest(Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} -} - -func (c *Conn) AllocNamedColorUnchecked(Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocNamedColorRequest(Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} -} - -// Request reply for AllocNamedColor -// size: 24 -type AllocNamedColorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Pixel uint32 - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 -} - -// Waits and reads reply data from request AllocNamedColor -func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocNamedColorReply(buf), nil -} - -// Read reply into structure from buffer for AllocNamedColor -func allocNamedColorReply(buf []byte) *AllocNamedColorReply { - v := new(AllocNamedColorReply) - 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.Pixel = Get32(buf[b:]) - b += 4 - - v.ExactRed = Get16(buf[b:]) - b += 2 - - v.ExactGreen = Get16(buf[b:]) - b += 2 - - v.ExactBlue = Get16(buf[b:]) - b += 2 - - v.VisualRed = Get16(buf[b:]) - b += 2 - - v.VisualGreen = Get16(buf[b:]) - b += 2 - - v.VisualBlue = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook AllocNamedColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocNamedColor -func (c *Conn) allocNamedColorRequest(Cmap Colormap, NameLen uint16, Name string) []byte { - size := pad((12 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 85 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request AllocColorCells -// size: 12 -type AllocColorCellsCookie struct { - *cookie -} - -func (c *Conn) AllocColorCells(Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocColorCellsRequest(Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} -} - -func (c *Conn) AllocColorCellsUnchecked(Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocColorCellsRequest(Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} -} - -// Request reply for AllocColorCells -// size: ((32 + pad((int(PixelsLen) * 4))) + pad((int(MasksLen) * 4))) -type AllocColorCellsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PixelsLen uint16 - MasksLen uint16 - // padding: 20 bytes - Pixels []uint32 // size: pad((int(PixelsLen) * 4)) - Masks []uint32 // size: pad((int(MasksLen) * 4)) -} - -// Waits and reads reply data from request AllocColorCells -func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorCellsReply(buf), nil -} - -// Read reply into structure from buffer for AllocColorCells -func allocColorCellsReply(buf []byte) *AllocColorCellsReply { - v := new(AllocColorCellsReply) - 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.PixelsLen = Get16(buf[b:]) - b += 2 - - v.MasksLen = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Masks = make([]uint32, v.MasksLen) - for i := 0; i < int(v.MasksLen); i++ { - v.Masks[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook AllocColorCellsCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocColorCells -func (c *Conn) allocColorCellsRequest(Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 86 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], Colors) - b += 2 - - Put16(buf[b:], Planes) - b += 2 - - return buf -} - -// Request AllocColorPlanes -// size: 16 -type AllocColorPlanesCookie struct { - *cookie -} - -func (c *Conn) AllocColorPlanes(Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocColorPlanesRequest(Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} -} - -func (c *Conn) AllocColorPlanesUnchecked(Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocColorPlanesRequest(Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} -} - -// Request reply for AllocColorPlanes -// size: (32 + pad((int(PixelsLen) * 4))) -type AllocColorPlanesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PixelsLen uint16 - // padding: 2 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 8 bytes - Pixels []uint32 // size: pad((int(PixelsLen) * 4)) -} - -// Waits and reads reply data from request AllocColorPlanes -func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorPlanesReply(buf), nil -} - -// Read reply into structure from buffer for AllocColorPlanes -func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { - v := new(AllocColorPlanesReply) - 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.PixelsLen = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.RedMask = Get32(buf[b:]) - b += 4 - - v.GreenMask = Get32(buf[b:]) - b += 4 - - v.BlueMask = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook AllocColorPlanesCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocColorPlanes -func (c *Conn) allocColorPlanesRequest(Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 87 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], Colors) - b += 2 - - Put16(buf[b:], Reds) - b += 2 - - Put16(buf[b:], Greens) - b += 2 - - Put16(buf[b:], Blues) - b += 2 - - return buf -} - -// Request FreeColors -// size: pad((12 + pad((len(Pixels) * 4)))) -type FreeColorsCookie struct { - *cookie -} - -// Write request to wire for FreeColors -func (c *Conn) FreeColors(Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeColorsRequest(Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} -} - -func (c *Conn) FreeColorsChecked(Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeColorsRequest(Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} -} - -func (cook FreeColorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeColors -func (c *Conn) freeColorsRequest(Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { - size := pad((12 + pad((len(Pixels) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 88 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put32(buf[b:], PlaneMask) - b += 4 - - for i := 0; i < int(len(Pixels)); i++ { - Put32(buf[b:], Pixels[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request StoreColors -// size: pad((8 + pad((len(Items) * 12)))) -type StoreColorsCookie struct { - *cookie -} - -// Write request to wire for StoreColors -func (c *Conn) StoreColors(Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.storeColorsRequest(Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} - -func (c *Conn) StoreColorsChecked(Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.storeColorsRequest(Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} - -func (cook StoreColorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for StoreColors -func (c *Conn) storeColorsRequest(Cmap Colormap, Items []Coloritem) []byte { - size := pad((8 + pad((len(Items) * 12)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 89 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - b += ColoritemListBytes(buf[b:], Items) - - return buf -} - -// Request StoreNamedColor -// size: pad((16 + pad((int(NameLen) * 1)))) -type StoreNamedColorCookie struct { - *cookie -} - -// Write request to wire for StoreNamedColor -func (c *Conn) StoreNamedColor(Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.storeNamedColorRequest(Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} - -func (c *Conn) StoreNamedColorChecked(Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.storeNamedColorRequest(Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} - -func (cook StoreNamedColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for StoreNamedColor -func (c *Conn) storeNamedColorRequest(Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { - size := pad((16 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 90 // request opcode - b += 1 - - buf[b] = Flags - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put32(buf[b:], Pixel) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request QueryColors -// size: pad((8 + pad((len(Pixels) * 4)))) -type QueryColorsCookie struct { - *cookie -} - -func (c *Conn) QueryColors(Cmap Colormap, Pixels []uint32) QueryColorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryColorsRequest(Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} -} - -func (c *Conn) QueryColorsUnchecked(Cmap Colormap, Pixels []uint32) QueryColorsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryColorsRequest(Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} -} - -// Request reply for QueryColors -// size: (32 + pad((int(ColorsLen) * 8))) -type QueryColorsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ColorsLen uint16 - // padding: 22 bytes - Colors []Rgb // size: pad((int(ColorsLen) * 8)) -} - -// Waits and reads reply data from request QueryColors -func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryColorsReply(buf), nil -} - -// Read reply into structure from buffer for QueryColors -func queryColorsReply(buf []byte) *QueryColorsReply { - v := new(QueryColorsReply) - 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.ColorsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Colors = make([]Rgb, v.ColorsLen) - b += ReadRgbList(buf[b:], v.Colors) - - return v -} - -func (cook QueryColorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryColors -func (c *Conn) queryColorsRequest(Cmap Colormap, Pixels []uint32) []byte { - size := pad((8 + pad((len(Pixels) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 91 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - for i := 0; i < int(len(Pixels)); i++ { - Put32(buf[b:], Pixels[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request LookupColor -// size: pad((12 + pad((int(NameLen) * 1)))) -type LookupColorCookie struct { - *cookie -} - -func (c *Conn) LookupColor(Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.lookupColorRequest(Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} -} - -func (c *Conn) LookupColorUnchecked(Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.lookupColorRequest(Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} -} - -// Request reply for LookupColor -// size: 20 -type LookupColorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 -} - -// Waits and reads reply data from request LookupColor -func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return lookupColorReply(buf), nil -} - -// Read reply into structure from buffer for LookupColor -func lookupColorReply(buf []byte) *LookupColorReply { - v := new(LookupColorReply) - 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.ExactRed = Get16(buf[b:]) - b += 2 - - v.ExactGreen = Get16(buf[b:]) - b += 2 - - v.ExactBlue = Get16(buf[b:]) - b += 2 - - v.VisualRed = Get16(buf[b:]) - b += 2 - - v.VisualGreen = Get16(buf[b:]) - b += 2 - - v.VisualBlue = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook LookupColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for LookupColor -func (c *Conn) lookupColorRequest(Cmap Colormap, NameLen uint16, Name string) []byte { - size := pad((12 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 92 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request CreateCursor -// size: 32 -type CreateCursorCookie struct { - *cookie -} - -// Write request to wire for CreateCursor -func (c *Conn) CreateCursor(Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createCursorRequest(Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} -} - -func (c *Conn) CreateCursorChecked(Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createCursorRequest(Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} -} - -func (cook CreateCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateCursor -func (c *Conn) createCursorRequest(Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 93 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Mask)) - b += 4 - - Put16(buf[b:], ForeRed) - b += 2 - - Put16(buf[b:], ForeGreen) - b += 2 - - Put16(buf[b:], ForeBlue) - b += 2 - - Put16(buf[b:], BackRed) - b += 2 - - Put16(buf[b:], BackGreen) - b += 2 - - Put16(buf[b:], BackBlue) - b += 2 - - Put16(buf[b:], X) - b += 2 - - Put16(buf[b:], Y) - b += 2 - - return buf -} - -// Request CreateGlyphCursor -// size: 32 -type CreateGlyphCursorCookie struct { - *cookie -} - -// Write request to wire for CreateGlyphCursor -func (c *Conn) CreateGlyphCursor(Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createGlyphCursorRequest(Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} - -func (c *Conn) CreateGlyphCursorChecked(Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createGlyphCursorRequest(Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} - -func (cook CreateGlyphCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateGlyphCursor -func (c *Conn) createGlyphCursorRequest(Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 94 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(SourceFont)) - b += 4 - - Put32(buf[b:], uint32(MaskFont)) - b += 4 - - Put16(buf[b:], SourceChar) - b += 2 - - Put16(buf[b:], MaskChar) - b += 2 - - Put16(buf[b:], ForeRed) - b += 2 - - Put16(buf[b:], ForeGreen) - b += 2 - - Put16(buf[b:], ForeBlue) - b += 2 - - Put16(buf[b:], BackRed) - b += 2 - - Put16(buf[b:], BackGreen) - b += 2 - - Put16(buf[b:], BackBlue) - b += 2 - - return buf -} - -// Request FreeCursor -// size: 8 -type FreeCursorCookie struct { - *cookie -} - -// Write request to wire for FreeCursor -func (c *Conn) FreeCursor(Cursor Cursor) FreeCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeCursorRequest(Cursor), cookie) - return FreeCursorCookie{cookie} -} - -func (c *Conn) FreeCursorChecked(Cursor Cursor) FreeCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeCursorRequest(Cursor), cookie) - return FreeCursorCookie{cookie} -} - -func (cook FreeCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeCursor -func (c *Conn) freeCursorRequest(Cursor Cursor) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 95 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - return buf -} - -// Request RecolorCursor -// size: 20 -type RecolorCursorCookie struct { - *cookie -} - -// Write request to wire for RecolorCursor -func (c *Conn) RecolorCursor(Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recolorCursorRequest(Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} -} - -func (c *Conn) RecolorCursorChecked(Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recolorCursorRequest(Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} -} - -func (cook RecolorCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecolorCursor -func (c *Conn) recolorCursorRequest(Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = 96 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put16(buf[b:], ForeRed) - b += 2 - - Put16(buf[b:], ForeGreen) - b += 2 - - Put16(buf[b:], ForeBlue) - b += 2 - - Put16(buf[b:], BackRed) - b += 2 - - Put16(buf[b:], BackGreen) - b += 2 - - Put16(buf[b:], BackBlue) - b += 2 - - return buf -} - -// Request QueryBestSize -// size: 12 -type QueryBestSizeCookie struct { - *cookie -} - -func (c *Conn) QueryBestSize(Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryBestSizeRequest(Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -func (c *Conn) QueryBestSizeUnchecked(Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryBestSizeRequest(Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -// Request reply for QueryBestSize -// size: 12 -type QueryBestSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint16 - Height uint16 -} - -// Waits and reads reply data from request QueryBestSize -func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryBestSizeReply(buf), nil -} - -// Read reply into structure from buffer for QueryBestSize -func queryBestSizeReply(buf []byte) *QueryBestSizeReply { - v := new(QueryBestSizeReply) - 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 = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook QueryBestSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryBestSize -func (c *Conn) queryBestSizeRequest(Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 97 // request opcode - b += 1 - - buf[b] = Class - 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:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request QueryExtension -// size: pad((8 + pad((int(NameLen) * 1)))) -type QueryExtensionCookie struct { - *cookie -} - -func (c *Conn) QueryExtension(NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryExtensionRequest(NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -func (c *Conn) QueryExtensionUnchecked(NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryExtensionRequest(NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -// Request reply for QueryExtension -// size: 12 -type QueryExtensionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Present bool - MajorOpcode byte - FirstEvent byte - FirstError byte -} - -// Waits and reads reply data from request QueryExtension -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryExtensionReply(buf), nil -} - -// Read reply into structure from buffer for QueryExtension -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) - 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.Present = true - } else { - v.Present = false - } - b += 1 - - v.MajorOpcode = buf[b] - b += 1 - - v.FirstEvent = buf[b] - b += 1 - - v.FirstError = buf[b] - b += 1 - - return v -} - -func (cook QueryExtensionCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryExtension -func (c *Conn) queryExtensionRequest(NameLen uint16, Name string) []byte { - size := pad((8 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 98 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request ListExtensions -// size: 4 -type ListExtensionsCookie struct { - *cookie -} - -func (c *Conn) ListExtensions() ListExtensionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listExtensionsRequest(), cookie) - return ListExtensionsCookie{cookie} -} - -func (c *Conn) ListExtensionsUnchecked() ListExtensionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listExtensionsRequest(), cookie) - return ListExtensionsCookie{cookie} -} - -// Request reply for ListExtensions -// size: (32 + StrListSize(Names)) -type ListExtensionsReply struct { - Sequence uint16 - Length uint32 - NamesLen byte - // padding: 24 bytes - Names []Str // size: StrListSize(Names) -} - -// Waits and reads reply data from request ListExtensions -func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listExtensionsReply(buf), nil -} - -// Read reply into structure from buffer for ListExtensions -func listExtensionsReply(buf []byte) *ListExtensionsReply { - v := new(ListExtensionsReply) - b := 1 // skip reply determinant - - v.NamesLen = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Names = make([]Str, v.NamesLen) - b += ReadStrList(buf[b:], v.Names) - - return v -} - -func (cook ListExtensionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListExtensions -func (c *Conn) listExtensionsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 99 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ChangeKeyboardMapping -// size: pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) -type ChangeKeyboardMappingCookie struct { - *cookie -} - -// Write request to wire for ChangeKeyboardMapping -func (c *Conn) ChangeKeyboardMapping(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeKeyboardMappingRequest(KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} -} - -func (c *Conn) ChangeKeyboardMappingChecked(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeKeyboardMappingRequest(KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} -} - -func (cook ChangeKeyboardMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeKeyboardMapping -func (c *Conn) changeKeyboardMappingRequest(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { - size := pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 100 // request opcode - b += 1 - - buf[b] = KeycodeCount - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = KeysymsPerKeycode - b += 1 - - b += 2 // padding - - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GetKeyboardMapping -// size: 8 -type GetKeyboardMappingCookie struct { - *cookie -} - -func (c *Conn) GetKeyboardMapping(FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getKeyboardMappingRequest(FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -func (c *Conn) GetKeyboardMappingUnchecked(FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getKeyboardMappingRequest(FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -// Request reply for GetKeyboardMapping -// size: (32 + pad((int(Length) * 4))) -type GetKeyboardMappingReply struct { - Sequence uint16 - Length uint32 - KeysymsPerKeycode byte - // padding: 24 bytes - Keysyms []Keysym // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GetKeyboardMapping -func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardMappingReply(buf), nil -} - -// Read reply into structure from buffer for GetKeyboardMapping -func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { - v := new(GetKeyboardMappingReply) - b := 1 // skip reply determinant - - v.KeysymsPerKeycode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keysyms = make([]Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GetKeyboardMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetKeyboardMapping -func (c *Conn) getKeyboardMappingRequest(FirstKeycode Keycode, Count byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 101 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - - return buf -} - -// Request ChangeKeyboardControl -// size: pad((4 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ChangeKeyboardControlCookie struct { - *cookie -} - -// Write request to wire for ChangeKeyboardControl -func (c *Conn) ChangeKeyboardControl(ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeKeyboardControlRequest(ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} -} - -func (c *Conn) ChangeKeyboardControlChecked(ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeKeyboardControlRequest(ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} -} - -func (cook ChangeKeyboardControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeKeyboardControl -func (c *Conn) changeKeyboardControlRequest(ValueMask uint32, ValueList []uint32) []byte { - size := pad((4 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 102 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - 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 GetKeyboardControl -// size: 4 -type GetKeyboardControlCookie struct { - *cookie -} - -func (c *Conn) GetKeyboardControl() GetKeyboardControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getKeyboardControlRequest(), cookie) - return GetKeyboardControlCookie{cookie} -} - -func (c *Conn) GetKeyboardControlUnchecked() GetKeyboardControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getKeyboardControlRequest(), cookie) - return GetKeyboardControlCookie{cookie} -} - -// Request reply for GetKeyboardControl -// size: 52 -type GetKeyboardControlReply struct { - Sequence uint16 - Length uint32 - GlobalAutoRepeat byte - LedMask uint32 - KeyClickPercent byte - BellPercent byte - BellPitch uint16 - BellDuration uint16 - // padding: 2 bytes - AutoRepeats []byte // size: 32 -} - -// Waits and reads reply data from request GetKeyboardControl -func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardControlReply(buf), nil -} - -// Read reply into structure from buffer for GetKeyboardControl -func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { - v := new(GetKeyboardControlReply) - b := 1 // skip reply determinant - - v.GlobalAutoRepeat = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.KeyClickPercent = buf[b] - b += 1 - - v.BellPercent = buf[b] - b += 1 - - v.BellPitch = Get16(buf[b:]) - b += 2 - - v.BellDuration = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += pad(int(32)) - - return v -} - -func (cook GetKeyboardControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetKeyboardControl -func (c *Conn) getKeyboardControlRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 103 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request Bell -// size: 4 -type BellCookie struct { - *cookie -} - -// Write request to wire for Bell -func (c *Conn) Bell(Percent int8) BellCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.bellRequest(Percent), cookie) - return BellCookie{cookie} -} - -func (c *Conn) BellChecked(Percent int8) BellCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.bellRequest(Percent), cookie) - return BellCookie{cookie} -} - -func (cook BellCookie) Check() error { - return cook.check() -} - -// Write request to wire for Bell -func (c *Conn) bellRequest(Percent int8) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 104 // request opcode - b += 1 - - buf[b] = byte(Percent) - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ChangePointerControl -// size: 12 -type ChangePointerControlCookie struct { - *cookie -} - -// Write request to wire for ChangePointerControl -func (c *Conn) ChangePointerControl(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changePointerControlRequest(AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -func (c *Conn) ChangePointerControlChecked(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changePointerControlRequest(AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -func (cook ChangePointerControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangePointerControl -func (c *Conn) changePointerControlRequest(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 105 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], uint16(AccelerationNumerator)) - b += 2 - - Put16(buf[b:], uint16(AccelerationDenominator)) - b += 2 - - Put16(buf[b:], uint16(Threshold)) - b += 2 - - if DoAcceleration { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if DoThreshold { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GetPointerControl -// size: 4 -type GetPointerControlCookie struct { - *cookie -} - -func (c *Conn) GetPointerControl() GetPointerControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getPointerControlRequest(), cookie) - return GetPointerControlCookie{cookie} -} - -func (c *Conn) GetPointerControlUnchecked() GetPointerControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getPointerControlRequest(), cookie) - return GetPointerControlCookie{cookie} -} - -// Request reply for GetPointerControl -// size: 32 -type GetPointerControlReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - AccelerationNumerator uint16 - AccelerationDenominator uint16 - Threshold uint16 - // padding: 18 bytes -} - -// Waits and reads reply data from request GetPointerControl -func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerControlReply(buf), nil -} - -// Read reply into structure from buffer for GetPointerControl -func getPointerControlReply(buf []byte) *GetPointerControlReply { - v := new(GetPointerControlReply) - 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.AccelerationNumerator = Get16(buf[b:]) - b += 2 - - v.AccelerationDenominator = Get16(buf[b:]) - b += 2 - - v.Threshold = Get16(buf[b:]) - b += 2 - - b += 18 // padding - - return v -} - -func (cook GetPointerControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetPointerControl -func (c *Conn) getPointerControlRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 106 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetScreenSaver -// size: 12 -type SetScreenSaverCookie struct { - *cookie -} - -// Write request to wire for SetScreenSaver -func (c *Conn) SetScreenSaver(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setScreenSaverRequest(Timeout, Interval, PreferBlanking, AllowExposures), cookie) - return SetScreenSaverCookie{cookie} -} - -func (c *Conn) SetScreenSaverChecked(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setScreenSaverRequest(Timeout, Interval, PreferBlanking, AllowExposures), cookie) - return SetScreenSaverCookie{cookie} -} - -func (cook SetScreenSaverCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetScreenSaver -func (c *Conn) setScreenSaverRequest(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 107 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], uint16(Timeout)) - b += 2 - - Put16(buf[b:], uint16(Interval)) - b += 2 - - buf[b] = PreferBlanking - b += 1 - - buf[b] = AllowExposures - b += 1 - - return buf -} - -// Request GetScreenSaver -// size: 4 -type GetScreenSaverCookie struct { - *cookie -} - -func (c *Conn) GetScreenSaver() GetScreenSaverCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getScreenSaverRequest(), cookie) - return GetScreenSaverCookie{cookie} -} - -func (c *Conn) GetScreenSaverUnchecked() GetScreenSaverCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getScreenSaverRequest(), cookie) - return GetScreenSaverCookie{cookie} -} - -// Request reply for GetScreenSaver -// size: 32 -type GetScreenSaverReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Timeout uint16 - Interval uint16 - PreferBlanking byte - AllowExposures byte - // padding: 18 bytes -} - -// Waits and reads reply data from request GetScreenSaver -func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenSaverReply(buf), nil -} - -// Read reply into structure from buffer for GetScreenSaver -func getScreenSaverReply(buf []byte) *GetScreenSaverReply { - v := new(GetScreenSaverReply) - 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.Timeout = Get16(buf[b:]) - b += 2 - - v.Interval = Get16(buf[b:]) - b += 2 - - v.PreferBlanking = buf[b] - b += 1 - - v.AllowExposures = buf[b] - b += 1 - - b += 18 // padding - - return v -} - -func (cook GetScreenSaverCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetScreenSaver -func (c *Conn) getScreenSaverRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 108 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ChangeHosts -// size: pad((8 + pad((int(AddressLen) * 1)))) -type ChangeHostsCookie struct { - *cookie -} - -// Write request to wire for ChangeHosts -func (c *Conn) ChangeHosts(Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeHostsRequest(Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} -} - -func (c *Conn) ChangeHostsChecked(Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeHostsRequest(Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} -} - -func (cook ChangeHostsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeHosts -func (c *Conn) changeHostsRequest(Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { - size := pad((8 + pad((int(AddressLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 109 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Family - b += 1 - - b += 1 // padding - - Put16(buf[b:], AddressLen) - b += 2 - - copy(buf[b:], Address[:AddressLen]) - b += pad(int(AddressLen)) - - return buf -} - -// Request ListHosts -// size: 4 -type ListHostsCookie struct { - *cookie -} - -func (c *Conn) ListHosts() ListHostsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listHostsRequest(), cookie) - return ListHostsCookie{cookie} -} - -func (c *Conn) ListHostsUnchecked() ListHostsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listHostsRequest(), cookie) - return ListHostsCookie{cookie} -} - -// Request reply for ListHosts -// size: (32 + HostListSize(Hosts)) -type ListHostsReply struct { - Sequence uint16 - Length uint32 - Mode byte - HostsLen uint16 - // padding: 22 bytes - Hosts []Host // size: HostListSize(Hosts) -} - -// Waits and reads reply data from request ListHosts -func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listHostsReply(buf), nil -} - -// Read reply into structure from buffer for ListHosts -func listHostsReply(buf []byte) *ListHostsReply { - v := new(ListHostsReply) - b := 1 // skip reply determinant - - v.Mode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.HostsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Hosts = make([]Host, v.HostsLen) - b += ReadHostList(buf[b:], v.Hosts) - - return v -} - -func (cook ListHostsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListHosts -func (c *Conn) listHostsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 110 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetAccessControl -// size: 4 -type SetAccessControlCookie struct { - *cookie -} - -// Write request to wire for SetAccessControl -func (c *Conn) SetAccessControl(Mode byte) SetAccessControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setAccessControlRequest(Mode), cookie) - return SetAccessControlCookie{cookie} -} - -func (c *Conn) SetAccessControlChecked(Mode byte) SetAccessControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setAccessControlRequest(Mode), cookie) - return SetAccessControlCookie{cookie} -} - -func (cook SetAccessControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetAccessControl -func (c *Conn) setAccessControlRequest(Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 111 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetCloseDownMode -// size: 4 -type SetCloseDownModeCookie struct { - *cookie -} - -// Write request to wire for SetCloseDownMode -func (c *Conn) SetCloseDownMode(Mode byte) SetCloseDownModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setCloseDownModeRequest(Mode), cookie) - return SetCloseDownModeCookie{cookie} -} - -func (c *Conn) SetCloseDownModeChecked(Mode byte) SetCloseDownModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setCloseDownModeRequest(Mode), cookie) - return SetCloseDownModeCookie{cookie} -} - -func (cook SetCloseDownModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetCloseDownMode -func (c *Conn) setCloseDownModeRequest(Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 112 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request KillClient -// size: 8 -type KillClientCookie struct { - *cookie -} - -// Write request to wire for KillClient -func (c *Conn) KillClient(Resource uint32) KillClientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.killClientRequest(Resource), cookie) - return KillClientCookie{cookie} -} - -func (c *Conn) KillClientChecked(Resource uint32) KillClientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.killClientRequest(Resource), cookie) - return KillClientCookie{cookie} -} - -func (cook KillClientCookie) Check() error { - return cook.check() -} - -// Write request to wire for KillClient -func (c *Conn) killClientRequest(Resource uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 113 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Resource) - b += 4 - - return buf -} - -// Request RotateProperties -// size: pad((12 + pad((int(AtomsLen) * 4)))) -type RotatePropertiesCookie struct { - *cookie -} - -// Write request to wire for RotateProperties -func (c *Conn) RotateProperties(Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.rotatePropertiesRequest(Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} -} - -func (c *Conn) RotatePropertiesChecked(Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.rotatePropertiesRequest(Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} -} - -func (cook RotatePropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RotateProperties -func (c *Conn) rotatePropertiesRequest(Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { - size := pad((12 + pad((int(AtomsLen) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 114 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], AtomsLen) - b += 2 - - Put16(buf[b:], uint16(Delta)) - b += 2 - - for i := 0; i < int(AtomsLen); i++ { - Put32(buf[b:], uint32(Atoms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request ForceScreenSaver -// size: 4 -type ForceScreenSaverCookie struct { - *cookie -} - -// Write request to wire for ForceScreenSaver -func (c *Conn) ForceScreenSaver(Mode byte) ForceScreenSaverCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.forceScreenSaverRequest(Mode), cookie) - return ForceScreenSaverCookie{cookie} -} - -func (c *Conn) ForceScreenSaverChecked(Mode byte) ForceScreenSaverCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.forceScreenSaverRequest(Mode), cookie) - return ForceScreenSaverCookie{cookie} -} - -func (cook ForceScreenSaverCookie) Check() error { - return cook.check() -} - -// Write request to wire for ForceScreenSaver -func (c *Conn) forceScreenSaverRequest(Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 115 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetPointerMapping -// size: pad((4 + pad((int(MapLen) * 1)))) -type SetPointerMappingCookie struct { - *cookie -} - -func (c *Conn) SetPointerMapping(MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.setPointerMappingRequest(MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -func (c *Conn) SetPointerMappingUnchecked(MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.setPointerMappingRequest(MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -// Request reply for SetPointerMapping -// size: 8 -type SetPointerMappingReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request SetPointerMapping -func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setPointerMappingReply(buf), nil -} - -// Read reply into structure from buffer for SetPointerMapping -func setPointerMappingReply(buf []byte) *SetPointerMappingReply { - v := new(SetPointerMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook SetPointerMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetPointerMapping -func (c *Conn) setPointerMappingRequest(MapLen byte, Map []byte) []byte { - size := pad((4 + pad((int(MapLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 116 // request opcode - b += 1 - - buf[b] = MapLen - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - copy(buf[b:], Map[:MapLen]) - b += pad(int(MapLen)) - - return buf -} - -// Request GetPointerMapping -// size: 4 -type GetPointerMappingCookie struct { - *cookie -} - -func (c *Conn) GetPointerMapping() GetPointerMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getPointerMappingRequest(), cookie) - return GetPointerMappingCookie{cookie} -} - -func (c *Conn) GetPointerMappingUnchecked() GetPointerMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getPointerMappingRequest(), cookie) - return GetPointerMappingCookie{cookie} -} - -// Request reply for GetPointerMapping -// size: (32 + pad((int(MapLen) * 1))) -type GetPointerMappingReply struct { - Sequence uint16 - Length uint32 - MapLen byte - // padding: 24 bytes - Map []byte // size: pad((int(MapLen) * 1)) -} - -// Waits and reads reply data from request GetPointerMapping -func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerMappingReply(buf), nil -} - -// Read reply into structure from buffer for GetPointerMapping -func getPointerMappingReply(buf []byte) *GetPointerMappingReply { - v := new(GetPointerMappingReply) - b := 1 // skip reply determinant - - v.MapLen = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Map = make([]byte, v.MapLen) - copy(v.Map[:v.MapLen], buf[b:]) - b += pad(int(v.MapLen)) - - return v -} - -func (cook GetPointerMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetPointerMapping -func (c *Conn) getPointerMappingRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 117 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetModifierMapping -// size: pad((4 + pad(((int(KeycodesPerModifier) * 8) * 1)))) -type SetModifierMappingCookie struct { - *cookie -} - -func (c *Conn) SetModifierMapping(KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.setModifierMappingRequest(KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -func (c *Conn) SetModifierMappingUnchecked(KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.setModifierMappingRequest(KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -// Request reply for SetModifierMapping -// size: 8 -type SetModifierMappingReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request SetModifierMapping -func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for SetModifierMapping -func setModifierMappingReply(buf []byte) *SetModifierMappingReply { - v := new(SetModifierMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook SetModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetModifierMapping -func (c *Conn) setModifierMappingRequest(KeycodesPerModifier byte, Keycodes []Keycode) []byte { - size := pad((4 + pad(((int(KeycodesPerModifier) * 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 118 // request opcode - b += 1 - - buf[b] = KeycodesPerModifier - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { - buf[b] = byte(Keycodes[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request GetModifierMapping -// size: 4 -type GetModifierMappingCookie struct { - *cookie -} - -func (c *Conn) GetModifierMapping() GetModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getModifierMappingRequest(), cookie) - return GetModifierMappingCookie{cookie} -} - -func (c *Conn) GetModifierMappingUnchecked() GetModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getModifierMappingRequest(), cookie) - return GetModifierMappingCookie{cookie} -} - -// Request reply for GetModifierMapping -// size: (32 + pad(((int(KeycodesPerModifier) * 8) * 1))) -type GetModifierMappingReply struct { - Sequence uint16 - Length uint32 - KeycodesPerModifier byte - // padding: 24 bytes - Keycodes []Keycode // size: pad(((int(KeycodesPerModifier) * 8) * 1)) -} - -// Waits and reads reply data from request GetModifierMapping -func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for GetModifierMapping -func getModifierMappingReply(buf []byte) *GetModifierMappingReply { - v := new(GetModifierMappingReply) - b := 1 // skip reply determinant - - v.KeycodesPerModifier = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) - for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { - v.Keycodes[i] = Keycode(buf[b]) - b += 1 - } - b = pad(b) - - return v -} - -func (cook GetModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetModifierMapping -func (c *Conn) getModifierMappingRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 119 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request NoOperation -// size: 4 -type NoOperationCookie struct { - *cookie -} - -// Write request to wire for NoOperation -func (c *Conn) NoOperation() NoOperationCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.noOperationRequest(), cookie) - return NoOperationCookie{cookie} -} - -func (c *Conn) NoOperationChecked() NoOperationCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.noOperationRequest(), cookie) - return NoOperationCookie{cookie} -} - -func (cook NoOperationCookie) Check() error { - return cook.check() -} - -// Write request to wire for NoOperation -func (c *Conn) noOperationRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 127 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} diff --git a/nexgb/auto_xselinux.go b/nexgb/auto_xselinux.go deleted file mode 100644 index 4e7ee81..0000000 --- a/nexgb/auto_xselinux.go +++ /dev/null @@ -1,1965 +0,0 @@ -package xgb - -/* - This file was generated by xselinux.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" - -// XselinuxInit must be called before using the SELinux extension. -func (c *Conn) XselinuxInit() error { - reply, err := c.QueryExtension(7, "SELinux").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named SELinux could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["SELinux"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["SELinux"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["SELinux"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["SELinux"] = make(map[int]newEventFun) - newExtErrorFuncs["SELinux"] = 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' - -// 'XselinuxListItem' struct definition -// Size: ((12 + pad((int(ObjectContextLen) * 1))) + pad((int(DataContextLen) * 1))) -type XselinuxListItem struct { - Name Atom - ObjectContextLen uint32 - DataContextLen uint32 - ObjectContext string // size: pad((int(ObjectContextLen) * 1)) - DataContext string // size: pad((int(DataContextLen) * 1)) -} - -// Struct read XselinuxListItem -func ReadXselinuxListItem(buf []byte, v *XselinuxListItem) int { - b := 0 - - v.Name = Atom(Get32(buf[b:])) - b += 4 - - v.ObjectContextLen = Get32(buf[b:]) - b += 4 - - v.DataContextLen = Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.ObjectContextLen) - copy(byteString[:v.ObjectContextLen], buf[b:]) - v.ObjectContext = string(byteString) - b += pad(int(v.ObjectContextLen)) - } - - { - byteString := make([]byte, v.DataContextLen) - copy(byteString[:v.DataContextLen], buf[b:]) - v.DataContext = string(byteString) - b += pad(int(v.DataContextLen)) - } - - return b -} - -// Struct list read XselinuxListItem -func ReadXselinuxListItemList(buf []byte, dest []XselinuxListItem) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XselinuxListItem{} - b += ReadXselinuxListItem(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XselinuxListItem -func (v XselinuxListItem) Bytes() []byte { - buf := make([]byte, ((12 + pad((int(v.ObjectContextLen) * 1))) + pad((int(v.DataContextLen) * 1)))) - b := 0 - - Put32(buf[b:], uint32(v.Name)) - b += 4 - - Put32(buf[b:], v.ObjectContextLen) - b += 4 - - Put32(buf[b:], v.DataContextLen) - b += 4 - - copy(buf[b:], v.ObjectContext[:v.ObjectContextLen]) - b += pad(int(v.ObjectContextLen)) - - copy(buf[b:], v.DataContext[:v.DataContextLen]) - b += pad(int(v.DataContextLen)) - - return buf -} - -// Write struct list XselinuxListItem -func XselinuxListItemListBytes(buf []byte, list []XselinuxListItem) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XselinuxListItem -func XselinuxListItemListSize(list []XselinuxListItem) int { - size := 0 - for _, item := range list { - size += ((12 + pad((int(item.ObjectContextLen) * 1))) + pad((int(item.DataContextLen) * 1))) - } - return size -} - -// Request XselinuxQueryVersion -// size: 8 -type XselinuxQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XselinuxQueryVersion(ClientMajor byte, ClientMinor byte) XselinuxQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxQueryVersionRequest(ClientMajor, ClientMinor), cookie) - return XselinuxQueryVersionCookie{cookie} -} - -func (c *Conn) XselinuxQueryVersionUnchecked(ClientMajor byte, ClientMinor byte) XselinuxQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxQueryVersionRequest(ClientMajor, ClientMinor), cookie) - return XselinuxQueryVersionCookie{cookie} -} - -// Request reply for XselinuxQueryVersion -// size: 12 -type XselinuxQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 -} - -// Waits and reads reply data from request XselinuxQueryVersion -func (cook XselinuxQueryVersionCookie) Reply() (*XselinuxQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxQueryVersion -func xselinuxQueryVersionReply(buf []byte) *XselinuxQueryVersionReply { - v := new(XselinuxQueryVersionReply) - 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 XselinuxQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxQueryVersion -func (c *Conn) xselinuxQueryVersionRequest(ClientMajor byte, ClientMinor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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 XselinuxSetDeviceCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetDeviceCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetDeviceCreateContext -func (c *Conn) XselinuxSetDeviceCreateContext(ContextLen uint32, Context string) XselinuxSetDeviceCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetDeviceCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetDeviceCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetDeviceCreateContextChecked(ContextLen uint32, Context string) XselinuxSetDeviceCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetDeviceCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetDeviceCreateContextCookie{cookie} -} - -func (cook XselinuxSetDeviceCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetDeviceCreateContext -func (c *Conn) xselinuxSetDeviceCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetDeviceCreateContext -// size: 4 -type XselinuxGetDeviceCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetDeviceCreateContext() XselinuxGetDeviceCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetDeviceCreateContextRequest(), cookie) - return XselinuxGetDeviceCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetDeviceCreateContextUnchecked() XselinuxGetDeviceCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetDeviceCreateContextRequest(), cookie) - return XselinuxGetDeviceCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetDeviceCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetDeviceCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetDeviceCreateContext -func (cook XselinuxGetDeviceCreateContextCookie) Reply() (*XselinuxGetDeviceCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetDeviceCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetDeviceCreateContext -func xselinuxGetDeviceCreateContextReply(buf []byte) *XselinuxGetDeviceCreateContextReply { - v := new(XselinuxGetDeviceCreateContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetDeviceCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetDeviceCreateContext -func (c *Conn) xselinuxGetDeviceCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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 XselinuxSetDeviceContext -// size: pad((12 + pad((int(ContextLen) * 1)))) -type XselinuxSetDeviceContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetDeviceContext -func (c *Conn) XselinuxSetDeviceContext(Device uint32, ContextLen uint32, Context string) XselinuxSetDeviceContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetDeviceContextRequest(Device, ContextLen, Context), cookie) - return XselinuxSetDeviceContextCookie{cookie} -} - -func (c *Conn) XselinuxSetDeviceContextChecked(Device uint32, ContextLen uint32, Context string) XselinuxSetDeviceContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetDeviceContextRequest(Device, ContextLen, Context), cookie) - return XselinuxSetDeviceContextCookie{cookie} -} - -func (cook XselinuxSetDeviceContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetDeviceContext -func (c *Conn) xselinuxSetDeviceContextRequest(Device uint32, ContextLen uint32, Context string) []byte { - size := pad((12 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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:], Device) - b += 4 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetDeviceContext -// size: 8 -type XselinuxGetDeviceContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetDeviceContext(Device uint32) XselinuxGetDeviceContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetDeviceContextRequest(Device), cookie) - return XselinuxGetDeviceContextCookie{cookie} -} - -func (c *Conn) XselinuxGetDeviceContextUnchecked(Device uint32) XselinuxGetDeviceContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetDeviceContextRequest(Device), cookie) - return XselinuxGetDeviceContextCookie{cookie} -} - -// Request reply for XselinuxGetDeviceContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetDeviceContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetDeviceContext -func (cook XselinuxGetDeviceContextCookie) Reply() (*XselinuxGetDeviceContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetDeviceContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetDeviceContext -func xselinuxGetDeviceContextReply(buf []byte) *XselinuxGetDeviceContextReply { - v := new(XselinuxGetDeviceContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetDeviceContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetDeviceContext -func (c *Conn) xselinuxGetDeviceContextRequest(Device uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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:], Device) - b += 4 - - return buf -} - -// Request XselinuxSetWindowCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetWindowCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetWindowCreateContext -func (c *Conn) XselinuxSetWindowCreateContext(ContextLen uint32, Context string) XselinuxSetWindowCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetWindowCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetWindowCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetWindowCreateContextChecked(ContextLen uint32, Context string) XselinuxSetWindowCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetWindowCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetWindowCreateContextCookie{cookie} -} - -func (cook XselinuxSetWindowCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetWindowCreateContext -func (c *Conn) xselinuxSetWindowCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetWindowCreateContext -// size: 4 -type XselinuxGetWindowCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetWindowCreateContext() XselinuxGetWindowCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetWindowCreateContextRequest(), cookie) - return XselinuxGetWindowCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetWindowCreateContextUnchecked() XselinuxGetWindowCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetWindowCreateContextRequest(), cookie) - return XselinuxGetWindowCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetWindowCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetWindowCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetWindowCreateContext -func (cook XselinuxGetWindowCreateContextCookie) Reply() (*XselinuxGetWindowCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetWindowCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetWindowCreateContext -func xselinuxGetWindowCreateContextReply(buf []byte) *XselinuxGetWindowCreateContextReply { - v := new(XselinuxGetWindowCreateContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetWindowCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetWindowCreateContext -func (c *Conn) xselinuxGetWindowCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetWindowContext -// size: 8 -type XselinuxGetWindowContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetWindowContext(Window Window) XselinuxGetWindowContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetWindowContextRequest(Window), cookie) - return XselinuxGetWindowContextCookie{cookie} -} - -func (c *Conn) XselinuxGetWindowContextUnchecked(Window Window) XselinuxGetWindowContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetWindowContextRequest(Window), cookie) - return XselinuxGetWindowContextCookie{cookie} -} - -// Request reply for XselinuxGetWindowContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetWindowContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetWindowContext -func (cook XselinuxGetWindowContextCookie) Reply() (*XselinuxGetWindowContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetWindowContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetWindowContext -func xselinuxGetWindowContextReply(buf []byte) *XselinuxGetWindowContextReply { - v := new(XselinuxGetWindowContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetWindowContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetWindowContext -func (c *Conn) xselinuxGetWindowContextRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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 XselinuxSetPropertyCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetPropertyCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetPropertyCreateContext -func (c *Conn) XselinuxSetPropertyCreateContext(ContextLen uint32, Context string) XselinuxSetPropertyCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetPropertyCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetPropertyCreateContextChecked(ContextLen uint32, Context string) XselinuxSetPropertyCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetPropertyCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyCreateContextCookie{cookie} -} - -func (cook XselinuxSetPropertyCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetPropertyCreateContext -func (c *Conn) xselinuxSetPropertyCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - 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:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetPropertyCreateContext -// size: 4 -type XselinuxGetPropertyCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyCreateContext() XselinuxGetPropertyCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyCreateContextRequest(), cookie) - return XselinuxGetPropertyCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyCreateContextUnchecked() XselinuxGetPropertyCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyCreateContextRequest(), cookie) - return XselinuxGetPropertyCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyCreateContext -func (cook XselinuxGetPropertyCreateContextCookie) Reply() (*XselinuxGetPropertyCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyCreateContext -func xselinuxGetPropertyCreateContextReply(buf []byte) *XselinuxGetPropertyCreateContextReply { - v := new(XselinuxGetPropertyCreateContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyCreateContext -func (c *Conn) xselinuxGetPropertyCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxSetPropertyUseContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetPropertyUseContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetPropertyUseContext -func (c *Conn) XselinuxSetPropertyUseContext(ContextLen uint32, Context string) XselinuxSetPropertyUseContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetPropertyUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyUseContextCookie{cookie} -} - -func (c *Conn) XselinuxSetPropertyUseContextChecked(ContextLen uint32, Context string) XselinuxSetPropertyUseContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetPropertyUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyUseContextCookie{cookie} -} - -func (cook XselinuxSetPropertyUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetPropertyUseContext -func (c *Conn) xselinuxSetPropertyUseContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetPropertyUseContext -// size: 4 -type XselinuxGetPropertyUseContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyUseContext() XselinuxGetPropertyUseContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyUseContextRequest(), cookie) - return XselinuxGetPropertyUseContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyUseContextUnchecked() XselinuxGetPropertyUseContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyUseContextRequest(), cookie) - return XselinuxGetPropertyUseContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyUseContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyUseContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyUseContext -func (cook XselinuxGetPropertyUseContextCookie) Reply() (*XselinuxGetPropertyUseContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyUseContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyUseContext -func xselinuxGetPropertyUseContextReply(buf []byte) *XselinuxGetPropertyUseContextReply { - v := new(XselinuxGetPropertyUseContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyUseContext -func (c *Conn) xselinuxGetPropertyUseContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetPropertyContext -// size: 12 -type XselinuxGetPropertyContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyContext(Window Window, Property Atom) XselinuxGetPropertyContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyContextRequest(Window, Property), cookie) - return XselinuxGetPropertyContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyContextUnchecked(Window Window, Property Atom) XselinuxGetPropertyContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyContextRequest(Window, Property), cookie) - return XselinuxGetPropertyContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyContext -func (cook XselinuxGetPropertyContextCookie) Reply() (*XselinuxGetPropertyContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyContext -func xselinuxGetPropertyContextReply(buf []byte) *XselinuxGetPropertyContextReply { - v := new(XselinuxGetPropertyContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyContext -func (c *Conn) xselinuxGetPropertyContextRequest(Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 12 // 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(Property)) - b += 4 - - return buf -} - -// Request XselinuxGetPropertyDataContext -// size: 12 -type XselinuxGetPropertyDataContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyDataContext(Window Window, Property Atom) XselinuxGetPropertyDataContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyDataContextRequest(Window, Property), cookie) - return XselinuxGetPropertyDataContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyDataContextUnchecked(Window Window, Property Atom) XselinuxGetPropertyDataContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyDataContextRequest(Window, Property), cookie) - return XselinuxGetPropertyDataContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyDataContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyDataContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyDataContext -func (cook XselinuxGetPropertyDataContextCookie) Reply() (*XselinuxGetPropertyDataContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyDataContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyDataContext -func xselinuxGetPropertyDataContextReply(buf []byte) *XselinuxGetPropertyDataContextReply { - v := new(XselinuxGetPropertyDataContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyDataContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyDataContext -func (c *Conn) xselinuxGetPropertyDataContextRequest(Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 13 // 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(Property)) - b += 4 - - return buf -} - -// Request XselinuxListProperties -// size: 8 -type XselinuxListPropertiesCookie struct { - *cookie -} - -func (c *Conn) XselinuxListProperties(Window Window) XselinuxListPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxListPropertiesRequest(Window), cookie) - return XselinuxListPropertiesCookie{cookie} -} - -func (c *Conn) XselinuxListPropertiesUnchecked(Window Window) XselinuxListPropertiesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxListPropertiesRequest(Window), cookie) - return XselinuxListPropertiesCookie{cookie} -} - -// Request reply for XselinuxListProperties -// size: (32 + XselinuxListItemListSize(Properties)) -type XselinuxListPropertiesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PropertiesLen uint32 - // padding: 20 bytes - Properties []XselinuxListItem // size: XselinuxListItemListSize(Properties) -} - -// Waits and reads reply data from request XselinuxListProperties -func (cook XselinuxListPropertiesCookie) Reply() (*XselinuxListPropertiesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxListPropertiesReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxListProperties -func xselinuxListPropertiesReply(buf []byte) *XselinuxListPropertiesReply { - v := new(XselinuxListPropertiesReply) - 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.PropertiesLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Properties = make([]XselinuxListItem, v.PropertiesLen) - b += ReadXselinuxListItemList(buf[b:], v.Properties) - - return v -} - -func (cook XselinuxListPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxListProperties -func (c *Conn) xselinuxListPropertiesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 14 // 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 XselinuxSetSelectionCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetSelectionCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetSelectionCreateContext -func (c *Conn) XselinuxSetSelectionCreateContext(ContextLen uint32, Context string) XselinuxSetSelectionCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetSelectionCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetSelectionCreateContextChecked(ContextLen uint32, Context string) XselinuxSetSelectionCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetSelectionCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionCreateContextCookie{cookie} -} - -func (cook XselinuxSetSelectionCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetSelectionCreateContext -func (c *Conn) xselinuxSetSelectionCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetSelectionCreateContext -// size: 4 -type XselinuxGetSelectionCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionCreateContext() XselinuxGetSelectionCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionCreateContextRequest(), cookie) - return XselinuxGetSelectionCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionCreateContextUnchecked() XselinuxGetSelectionCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionCreateContextRequest(), cookie) - return XselinuxGetSelectionCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionCreateContext -func (cook XselinuxGetSelectionCreateContextCookie) Reply() (*XselinuxGetSelectionCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionCreateContext -func xselinuxGetSelectionCreateContextReply(buf []byte) *XselinuxGetSelectionCreateContextReply { - v := new(XselinuxGetSelectionCreateContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionCreateContext -func (c *Conn) xselinuxGetSelectionCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxSetSelectionUseContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetSelectionUseContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetSelectionUseContext -func (c *Conn) XselinuxSetSelectionUseContext(ContextLen uint32, Context string) XselinuxSetSelectionUseContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetSelectionUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionUseContextCookie{cookie} -} - -func (c *Conn) XselinuxSetSelectionUseContextChecked(ContextLen uint32, Context string) XselinuxSetSelectionUseContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetSelectionUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionUseContextCookie{cookie} -} - -func (cook XselinuxSetSelectionUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetSelectionUseContext -func (c *Conn) xselinuxSetSelectionUseContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetSelectionUseContext -// size: 4 -type XselinuxGetSelectionUseContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionUseContext() XselinuxGetSelectionUseContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionUseContextRequest(), cookie) - return XselinuxGetSelectionUseContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionUseContextUnchecked() XselinuxGetSelectionUseContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionUseContextRequest(), cookie) - return XselinuxGetSelectionUseContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionUseContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionUseContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionUseContext -func (cook XselinuxGetSelectionUseContextCookie) Reply() (*XselinuxGetSelectionUseContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionUseContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionUseContext -func xselinuxGetSelectionUseContextReply(buf []byte) *XselinuxGetSelectionUseContextReply { - v := new(XselinuxGetSelectionUseContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionUseContext -func (c *Conn) xselinuxGetSelectionUseContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetSelectionContext -// size: 8 -type XselinuxGetSelectionContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionContext(Selection Atom) XselinuxGetSelectionContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionContextRequest(Selection), cookie) - return XselinuxGetSelectionContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionContextUnchecked(Selection Atom) XselinuxGetSelectionContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionContextRequest(Selection), cookie) - return XselinuxGetSelectionContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionContext -func (cook XselinuxGetSelectionContextCookie) Reply() (*XselinuxGetSelectionContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionContext -func xselinuxGetSelectionContextReply(buf []byte) *XselinuxGetSelectionContextReply { - v := new(XselinuxGetSelectionContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionContext -func (c *Conn) xselinuxGetSelectionContextRequest(Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// Request XselinuxGetSelectionDataContext -// size: 8 -type XselinuxGetSelectionDataContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionDataContext(Selection Atom) XselinuxGetSelectionDataContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionDataContextRequest(Selection), cookie) - return XselinuxGetSelectionDataContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionDataContextUnchecked(Selection Atom) XselinuxGetSelectionDataContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionDataContextRequest(Selection), cookie) - return XselinuxGetSelectionDataContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionDataContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionDataContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionDataContext -func (cook XselinuxGetSelectionDataContextCookie) Reply() (*XselinuxGetSelectionDataContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionDataContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionDataContext -func xselinuxGetSelectionDataContextReply(buf []byte) *XselinuxGetSelectionDataContextReply { - v := new(XselinuxGetSelectionDataContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionDataContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionDataContext -func (c *Conn) xselinuxGetSelectionDataContextRequest(Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// Request XselinuxListSelections -// size: 4 -type XselinuxListSelectionsCookie struct { - *cookie -} - -func (c *Conn) XselinuxListSelections() XselinuxListSelectionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxListSelectionsRequest(), cookie) - return XselinuxListSelectionsCookie{cookie} -} - -func (c *Conn) XselinuxListSelectionsUnchecked() XselinuxListSelectionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxListSelectionsRequest(), cookie) - return XselinuxListSelectionsCookie{cookie} -} - -// Request reply for XselinuxListSelections -// size: (32 + XselinuxListItemListSize(Selections)) -type XselinuxListSelectionsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - SelectionsLen uint32 - // padding: 20 bytes - Selections []XselinuxListItem // size: XselinuxListItemListSize(Selections) -} - -// Waits and reads reply data from request XselinuxListSelections -func (cook XselinuxListSelectionsCookie) Reply() (*XselinuxListSelectionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxListSelectionsReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxListSelections -func xselinuxListSelectionsReply(buf []byte) *XselinuxListSelectionsReply { - v := new(XselinuxListSelectionsReply) - 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.SelectionsLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Selections = make([]XselinuxListItem, v.SelectionsLen) - b += ReadXselinuxListItemList(buf[b:], v.Selections) - - return v -} - -func (cook XselinuxListSelectionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxListSelections -func (c *Conn) xselinuxListSelectionsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetClientContext -// size: 8 -type XselinuxGetClientContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetClientContext(Resource uint32) XselinuxGetClientContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetClientContextRequest(Resource), cookie) - return XselinuxGetClientContextCookie{cookie} -} - -func (c *Conn) XselinuxGetClientContextUnchecked(Resource uint32) XselinuxGetClientContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetClientContextRequest(Resource), cookie) - return XselinuxGetClientContextCookie{cookie} -} - -// Request reply for XselinuxGetClientContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetClientContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetClientContext -func (cook XselinuxGetClientContextCookie) Reply() (*XselinuxGetClientContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetClientContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetClientContext -func xselinuxGetClientContextReply(buf []byte) *XselinuxGetClientContextReply { - v := new(XselinuxGetClientContextReply) - 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.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetClientContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetClientContext -func (c *Conn) xselinuxGetClientContextRequest(Resource uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Resource) - b += 4 - - return buf -} diff --git a/nexgb/auto_xtest.go b/nexgb/auto_xtest.go deleted file mode 100644 index f3b92a2..0000000 --- a/nexgb/auto_xtest.go +++ /dev/null @@ -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 -} diff --git a/nexgb/auto_xv.go b/nexgb/auto_xv.go deleted file mode 100644 index 25f0491..0000000 --- a/nexgb/auto_xv.go +++ /dev/null @@ -1,2780 +0,0 @@ -package xgb - -/* - This file was generated by xv.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 "xproto" -// import "shm" - -// XvInit must be called before using the XVideo extension. -func (c *Conn) XvInit() error { - reply, err := c.QueryExtension(6, "XVideo").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XVideo could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XVideo"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XVideo"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XVideo"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XVideo"] = make(map[int]newEventFun) - newExtErrorFuncs["XVideo"] = 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 ( - XvTypeInputMask = 1 - XvTypeOutputMask = 2 - XvTypeVideoMask = 4 - XvTypeStillMask = 8 - XvTypeImageMask = 16 -) - -const ( - XvImageFormatInfoTypeRgb = 0 - XvImageFormatInfoTypeYuv = 1 -) - -const ( - XvImageFormatInfoFormatPacked = 0 - XvImageFormatInfoFormatPlanar = 1 -) - -const ( - XvAttributeFlagGettable = 1 - XvAttributeFlagSettable = 2 -) - -const ( - XvVideoNotifyReasonStarted = 0 - XvVideoNotifyReasonStopped = 1 - XvVideoNotifyReasonBusy = 2 - XvVideoNotifyReasonPreempted = 3 - XvVideoNotifyReasonHardError = 4 -) - -const ( - XvScanlineOrderTopToBottom = 0 - XvScanlineOrderBottomToTop = 1 -) - -const ( - XvGrabPortStatusSuccess = 0 - XvGrabPortStatusBadExtension = 1 - XvGrabPortStatusAlreadyGrabbed = 2 - XvGrabPortStatusInvalidTime = 3 - XvGrabPortStatusBadReply = 4 - XvGrabPortStatusBadAlloc = 5 -) - -type XvPort uint32 - -func (c *Conn) NewXvPortId() (XvPort, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvPort(id), nil -} - -type XvEncoding uint32 - -func (c *Conn) NewXvEncodingId() (XvEncoding, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvEncoding(id), nil -} - -// 'XvRational' struct definition -// Size: 8 -type XvRational struct { - Numerator int32 - Denominator int32 -} - -// Struct read XvRational -func ReadXvRational(buf []byte, v *XvRational) int { - b := 0 - - v.Numerator = int32(Get32(buf[b:])) - b += 4 - - v.Denominator = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XvRational -func ReadXvRationalList(buf []byte, dest []XvRational) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvRational{} - b += ReadXvRational(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvRational -func (v XvRational) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Numerator)) - b += 4 - - Put32(buf[b:], uint32(v.Denominator)) - b += 4 - - return buf -} - -// Write struct list XvRational -func XvRationalListBytes(buf []byte, list []XvRational) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XvFormat' struct definition -// Size: 8 -type XvFormat struct { - Visual Visualid - Depth byte - // padding: 3 bytes -} - -// Struct read XvFormat -func ReadXvFormat(buf []byte, v *XvFormat) int { - b := 0 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Depth = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XvFormat -func ReadXvFormatList(buf []byte, dest []XvFormat) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvFormat{} - b += ReadXvFormat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvFormat -func (v XvFormat) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Visual)) - b += 4 - - buf[b] = v.Depth - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XvFormat -func XvFormatListBytes(buf []byte, list []XvFormat) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XvAdaptorInfo' struct definition -// Size: ((12 + pad((int(NameSize) * 1))) + pad((int(NumFormats) * 8))) -type XvAdaptorInfo struct { - BaseId XvPort - NameSize uint16 - NumPorts uint16 - NumFormats uint16 - Type byte - // padding: 1 bytes - Name string // size: pad((int(NameSize) * 1)) - Formats []XvFormat // size: pad((int(NumFormats) * 8)) -} - -// Struct read XvAdaptorInfo -func ReadXvAdaptorInfo(buf []byte, v *XvAdaptorInfo) int { - b := 0 - - v.BaseId = XvPort(Get32(buf[b:])) - b += 4 - - v.NameSize = Get16(buf[b:]) - b += 2 - - v.NumPorts = Get16(buf[b:]) - b += 2 - - v.NumFormats = Get16(buf[b:]) - b += 2 - - v.Type = buf[b] - b += 1 - - b += 1 // padding - - { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameSize)) - } - - v.Formats = make([]XvFormat, v.NumFormats) - b += ReadXvFormatList(buf[b:], v.Formats) - - return b -} - -// Struct list read XvAdaptorInfo -func ReadXvAdaptorInfoList(buf []byte, dest []XvAdaptorInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvAdaptorInfo{} - b += ReadXvAdaptorInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvAdaptorInfo -func (v XvAdaptorInfo) Bytes() []byte { - buf := make([]byte, ((12 + pad((int(v.NameSize) * 1))) + pad((int(v.NumFormats) * 8)))) - b := 0 - - Put32(buf[b:], uint32(v.BaseId)) - b += 4 - - Put16(buf[b:], v.NameSize) - b += 2 - - Put16(buf[b:], v.NumPorts) - b += 2 - - Put16(buf[b:], v.NumFormats) - b += 2 - - buf[b] = v.Type - b += 1 - - b += 1 // padding - - copy(buf[b:], v.Name[:v.NameSize]) - b += pad(int(v.NameSize)) - - b += XvFormatListBytes(buf[b:], v.Formats) - - return buf -} - -// Write struct list XvAdaptorInfo -func XvAdaptorInfoListBytes(buf []byte, list []XvAdaptorInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvAdaptorInfo -func XvAdaptorInfoListSize(list []XvAdaptorInfo) int { - size := 0 - for _, item := range list { - size += ((12 + pad((int(item.NameSize) * 1))) + pad((int(item.NumFormats) * 8))) - } - return size -} - -// 'XvEncodingInfo' struct definition -// Size: (20 + pad((int(NameSize) * 1))) -type XvEncodingInfo struct { - Encoding XvEncoding - NameSize uint16 - Width uint16 - Height uint16 - // padding: 2 bytes - Rate XvRational - Name string // size: pad((int(NameSize) * 1)) -} - -// Struct read XvEncodingInfo -func ReadXvEncodingInfo(buf []byte, v *XvEncodingInfo) int { - b := 0 - - v.Encoding = XvEncoding(Get32(buf[b:])) - b += 4 - - v.NameSize = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Rate = XvRational{} - b += ReadXvRational(buf[b:], &v.Rate) - - { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameSize)) - } - - return b -} - -// Struct list read XvEncodingInfo -func ReadXvEncodingInfoList(buf []byte, dest []XvEncodingInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvEncodingInfo{} - b += ReadXvEncodingInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvEncodingInfo -func (v XvEncodingInfo) Bytes() []byte { - buf := make([]byte, (20 + pad((int(v.NameSize) * 1)))) - b := 0 - - Put32(buf[b:], uint32(v.Encoding)) - b += 4 - - Put16(buf[b:], v.NameSize) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - b += 2 // padding - - { - structBytes := v.Rate.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - copy(buf[b:], v.Name[:v.NameSize]) - b += pad(int(v.NameSize)) - - return buf -} - -// Write struct list XvEncodingInfo -func XvEncodingInfoListBytes(buf []byte, list []XvEncodingInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvEncodingInfo -func XvEncodingInfoListSize(list []XvEncodingInfo) int { - size := 0 - for _, item := range list { - size += (20 + pad((int(item.NameSize) * 1))) - } - return size -} - -// 'XvImage' struct definition -// Size: (((16 + pad((int(NumPlanes) * 4))) + pad((int(NumPlanes) * 4))) + pad((int(DataSize) * 1))) -type XvImage struct { - Id uint32 - Width uint16 - Height uint16 - DataSize uint32 - NumPlanes uint32 - Pitches []uint32 // size: pad((int(NumPlanes) * 4)) - Offsets []uint32 // size: pad((int(NumPlanes) * 4)) - Data []byte // size: pad((int(DataSize) * 1)) -} - -// Struct read XvImage -func ReadXvImage(buf []byte, v *XvImage) int { - b := 0 - - v.Id = Get32(buf[b:]) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.DataSize = Get32(buf[b:]) - b += 4 - - v.NumPlanes = Get32(buf[b:]) - b += 4 - - v.Pitches = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Pitches[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Offsets = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Offsets[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Data = make([]byte, v.DataSize) - copy(v.Data[:v.DataSize], buf[b:]) - b += pad(int(v.DataSize)) - - return b -} - -// Struct list read XvImage -func ReadXvImageList(buf []byte, dest []XvImage) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvImage{} - b += ReadXvImage(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvImage -func (v XvImage) Bytes() []byte { - buf := make([]byte, (((16 + pad((int(v.NumPlanes) * 4))) + pad((int(v.NumPlanes) * 4))) + pad((int(v.DataSize) * 1)))) - b := 0 - - Put32(buf[b:], v.Id) - b += 4 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put32(buf[b:], v.DataSize) - b += 4 - - Put32(buf[b:], v.NumPlanes) - b += 4 - - for i := 0; i < int(v.NumPlanes); i++ { - Put32(buf[b:], v.Pitches[i]) - b += 4 - } - b = pad(b) - - for i := 0; i < int(v.NumPlanes); i++ { - Put32(buf[b:], v.Offsets[i]) - b += 4 - } - b = pad(b) - - copy(buf[b:], v.Data[:v.DataSize]) - b += pad(int(v.DataSize)) - - return buf -} - -// Write struct list XvImage -func XvImageListBytes(buf []byte, list []XvImage) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvImage -func XvImageListSize(list []XvImage) int { - size := 0 - for _, item := range list { - size += (((16 + pad((int(item.NumPlanes) * 4))) + pad((int(item.NumPlanes) * 4))) + pad((int(item.DataSize) * 1))) - } - return size -} - -// 'XvAttributeInfo' struct definition -// Size: (16 + pad((int(Size) * 1))) -type XvAttributeInfo struct { - Flags uint32 - Min int32 - Max int32 - Size uint32 - Name string // size: pad((int(Size) * 1)) -} - -// Struct read XvAttributeInfo -func ReadXvAttributeInfo(buf []byte, v *XvAttributeInfo) int { - b := 0 - - v.Flags = Get32(buf[b:]) - b += 4 - - v.Min = int32(Get32(buf[b:])) - b += 4 - - v.Max = int32(Get32(buf[b:])) - b += 4 - - v.Size = Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.Size) - copy(byteString[:v.Size], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.Size)) - } - - return b -} - -// Struct list read XvAttributeInfo -func ReadXvAttributeInfoList(buf []byte, dest []XvAttributeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvAttributeInfo{} - b += ReadXvAttributeInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvAttributeInfo -func (v XvAttributeInfo) Bytes() []byte { - buf := make([]byte, (16 + pad((int(v.Size) * 1)))) - b := 0 - - Put32(buf[b:], v.Flags) - b += 4 - - Put32(buf[b:], uint32(v.Min)) - b += 4 - - Put32(buf[b:], uint32(v.Max)) - b += 4 - - Put32(buf[b:], v.Size) - b += 4 - - copy(buf[b:], v.Name[:v.Size]) - b += pad(int(v.Size)) - - return buf -} - -// Write struct list XvAttributeInfo -func XvAttributeInfoListBytes(buf []byte, list []XvAttributeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvAttributeInfo -func XvAttributeInfoListSize(list []XvAttributeInfo) int { - size := 0 - for _, item := range list { - size += (16 + pad((int(item.Size) * 1))) - } - return size -} - -// 'XvImageFormatInfo' struct definition -// Size: 128 -type XvImageFormatInfo struct { - Id uint32 - Type byte - ByteOrder byte - // padding: 2 bytes - Guid []byte // size: 16 - Bpp byte - NumPlanes byte - // padding: 2 bytes - Depth byte - // padding: 3 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - Format byte - // padding: 3 bytes - YSampleBits uint32 - USampleBits uint32 - VSampleBits uint32 - VhorzYPeriod uint32 - VhorzUPeriod uint32 - VhorzVPeriod uint32 - VvertYPeriod uint32 - VvertUPeriod uint32 - VvertVPeriod uint32 - VcompOrder []byte // size: 32 - VscanlineOrder byte - // padding: 11 bytes -} - -// Struct read XvImageFormatInfo -func ReadXvImageFormatInfo(buf []byte, v *XvImageFormatInfo) int { - b := 0 - - v.Id = Get32(buf[b:]) - b += 4 - - v.Type = buf[b] - b += 1 - - v.ByteOrder = buf[b] - b += 1 - - b += 2 // padding - - v.Guid = make([]byte, 16) - copy(v.Guid[:16], buf[b:]) - b += pad(int(16)) - - v.Bpp = buf[b] - b += 1 - - v.NumPlanes = buf[b] - b += 1 - - b += 2 // padding - - v.Depth = buf[b] - b += 1 - - b += 3 // padding - - v.RedMask = Get32(buf[b:]) - b += 4 - - v.GreenMask = Get32(buf[b:]) - b += 4 - - v.BlueMask = Get32(buf[b:]) - b += 4 - - v.Format = buf[b] - b += 1 - - b += 3 // padding - - v.YSampleBits = Get32(buf[b:]) - b += 4 - - v.USampleBits = Get32(buf[b:]) - b += 4 - - v.VSampleBits = Get32(buf[b:]) - b += 4 - - v.VhorzYPeriod = Get32(buf[b:]) - b += 4 - - v.VhorzUPeriod = Get32(buf[b:]) - b += 4 - - v.VhorzVPeriod = Get32(buf[b:]) - b += 4 - - v.VvertYPeriod = Get32(buf[b:]) - b += 4 - - v.VvertUPeriod = Get32(buf[b:]) - b += 4 - - v.VvertVPeriod = Get32(buf[b:]) - b += 4 - - v.VcompOrder = make([]byte, 32) - copy(v.VcompOrder[:32], buf[b:]) - b += pad(int(32)) - - v.VscanlineOrder = buf[b] - b += 1 - - b += 11 // padding - - return b -} - -// Struct list read XvImageFormatInfo -func ReadXvImageFormatInfoList(buf []byte, dest []XvImageFormatInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvImageFormatInfo{} - b += ReadXvImageFormatInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvImageFormatInfo -func (v XvImageFormatInfo) Bytes() []byte { - buf := make([]byte, 128) - b := 0 - - Put32(buf[b:], v.Id) - b += 4 - - buf[b] = v.Type - b += 1 - - buf[b] = v.ByteOrder - b += 1 - - b += 2 // padding - - copy(buf[b:], v.Guid[:16]) - b += pad(int(16)) - - buf[b] = v.Bpp - b += 1 - - buf[b] = v.NumPlanes - b += 1 - - b += 2 // padding - - buf[b] = v.Depth - b += 1 - - b += 3 // padding - - Put32(buf[b:], v.RedMask) - b += 4 - - Put32(buf[b:], v.GreenMask) - b += 4 - - Put32(buf[b:], v.BlueMask) - b += 4 - - buf[b] = v.Format - b += 1 - - b += 3 // padding - - Put32(buf[b:], v.YSampleBits) - b += 4 - - Put32(buf[b:], v.USampleBits) - b += 4 - - Put32(buf[b:], v.VSampleBits) - b += 4 - - Put32(buf[b:], v.VhorzYPeriod) - b += 4 - - Put32(buf[b:], v.VhorzUPeriod) - b += 4 - - Put32(buf[b:], v.VhorzVPeriod) - b += 4 - - Put32(buf[b:], v.VvertYPeriod) - b += 4 - - Put32(buf[b:], v.VvertUPeriod) - b += 4 - - Put32(buf[b:], v.VvertVPeriod) - b += 4 - - copy(buf[b:], v.VcompOrder[:32]) - b += pad(int(32)) - - buf[b] = v.VscanlineOrder - b += 1 - - b += 11 // padding - - return buf -} - -// Write struct list XvImageFormatInfo -func XvImageFormatInfoListBytes(buf []byte, list []XvImageFormatInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvImageFormatInfo -func XvImageFormatInfoListSize(list []XvImageFormatInfo) int { - size := 0 - for _ = range list { - size += 128 - } - return size -} - -// Event definition XvVideoNotify (0) -// Size: 32 - -const XvVideoNotify = 0 - -type XvVideoNotifyEvent struct { - Sequence uint16 - Reason byte - Time Timestamp - Drawable Drawable - Port XvPort -} - -// Event read XvVideoNotify -func NewXvVideoNotifyEvent(buf []byte) Event { - v := XvVideoNotifyEvent{} - b := 1 // don't read event number - - v.Reason = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.Port = XvPort(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write XvVideoNotify -func (v XvVideoNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Reason - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], uint32(v.Port)) - b += 4 - - return buf -} - -func (v XvVideoNotifyEvent) ImplementsEvent() {} - -func (v XvVideoNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XvVideoNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Reason: %d", v.Reason)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("Port: %d", v.Port)) - return "XvVideoNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XVideo"][0] = NewXvVideoNotifyEvent -} - -// Event definition XvPortNotify (1) -// Size: 32 - -const XvPortNotify = 1 - -type XvPortNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Port XvPort - Attribute Atom - Value int32 -} - -// Event read XvPortNotify -func NewXvPortNotifyEvent(buf []byte) Event { - v := XvPortNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Port = XvPort(Get32(buf[b:])) - b += 4 - - v.Attribute = Atom(Get32(buf[b:])) - b += 4 - - v.Value = int32(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write XvPortNotify -func (v XvPortNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Port)) - b += 4 - - Put32(buf[b:], uint32(v.Attribute)) - b += 4 - - Put32(buf[b:], uint32(v.Value)) - b += 4 - - return buf -} - -func (v XvPortNotifyEvent) ImplementsEvent() {} - -func (v XvPortNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XvPortNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Port: %d", v.Port)) - fieldVals = append(fieldVals, sprintf("Attribute: %d", v.Attribute)) - fieldVals = append(fieldVals, sprintf("Value: %d", v.Value)) - return "XvPortNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XVideo"][1] = NewXvPortNotifyEvent -} - -// Error definition XvBadPort (0) -// Size: 32 - -const BadXvBadPort = 0 - -type XvBadPortError struct { - Sequence uint16 - NiceName string -} - -// Error read XvBadPort -func NewXvBadPortError(buf []byte) Error { - v := XvBadPortError{} - v.NiceName = "XvBadPort" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XvBadPortError) ImplementsError() {} - -func (err XvBadPortError) SequenceId() uint16 { - return err.Sequence -} - -func (err XvBadPortError) BadId() uint32 { - return 0 -} - -func (err XvBadPortError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXvBadPort {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XVideo"][0] = NewXvBadPortError -} - -// Error definition XvBadEncoding (1) -// Size: 32 - -const BadXvBadEncoding = 1 - -type XvBadEncodingError struct { - Sequence uint16 - NiceName string -} - -// Error read XvBadEncoding -func NewXvBadEncodingError(buf []byte) Error { - v := XvBadEncodingError{} - v.NiceName = "XvBadEncoding" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XvBadEncodingError) ImplementsError() {} - -func (err XvBadEncodingError) SequenceId() uint16 { - return err.Sequence -} - -func (err XvBadEncodingError) BadId() uint32 { - return 0 -} - -func (err XvBadEncodingError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXvBadEncoding {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XVideo"][1] = NewXvBadEncodingError -} - -// Error definition XvBadControl (2) -// Size: 32 - -const BadXvBadControl = 2 - -type XvBadControlError struct { - Sequence uint16 - NiceName string -} - -// Error read XvBadControl -func NewXvBadControlError(buf []byte) Error { - v := XvBadControlError{} - v.NiceName = "XvBadControl" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XvBadControlError) ImplementsError() {} - -func (err XvBadControlError) SequenceId() uint16 { - return err.Sequence -} - -func (err XvBadControlError) BadId() uint32 { - return 0 -} - -func (err XvBadControlError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXvBadControl {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XVideo"][2] = NewXvBadControlError -} - -// Request XvQueryExtension -// size: 4 -type XvQueryExtensionCookie struct { - *cookie -} - -func (c *Conn) XvQueryExtension() XvQueryExtensionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryExtensionRequest(), cookie) - return XvQueryExtensionCookie{cookie} -} - -func (c *Conn) XvQueryExtensionUnchecked() XvQueryExtensionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryExtensionRequest(), cookie) - return XvQueryExtensionCookie{cookie} -} - -// Request reply for XvQueryExtension -// size: 12 -type XvQueryExtensionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Major uint16 - Minor uint16 -} - -// Waits and reads reply data from request XvQueryExtension -func (cook XvQueryExtensionCookie) Reply() (*XvQueryExtensionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryExtensionReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryExtension -func xvQueryExtensionReply(buf []byte) *XvQueryExtensionReply { - v := new(XvQueryExtensionReply) - 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 XvQueryExtensionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryExtension -func (c *Conn) xvQueryExtensionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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 XvQueryAdaptors -// size: 8 -type XvQueryAdaptorsCookie struct { - *cookie -} - -func (c *Conn) XvQueryAdaptors(Window Window) XvQueryAdaptorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryAdaptorsRequest(Window), cookie) - return XvQueryAdaptorsCookie{cookie} -} - -func (c *Conn) XvQueryAdaptorsUnchecked(Window Window) XvQueryAdaptorsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryAdaptorsRequest(Window), cookie) - return XvQueryAdaptorsCookie{cookie} -} - -// Request reply for XvQueryAdaptors -// size: (32 + XvAdaptorInfoListSize(Info)) -type XvQueryAdaptorsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAdaptors uint16 - // padding: 22 bytes - Info []XvAdaptorInfo // size: XvAdaptorInfoListSize(Info) -} - -// Waits and reads reply data from request XvQueryAdaptors -func (cook XvQueryAdaptorsCookie) Reply() (*XvQueryAdaptorsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryAdaptorsReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryAdaptors -func xvQueryAdaptorsReply(buf []byte) *XvQueryAdaptorsReply { - v := new(XvQueryAdaptorsReply) - 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.NumAdaptors = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]XvAdaptorInfo, v.NumAdaptors) - b += ReadXvAdaptorInfoList(buf[b:], v.Info) - - return v -} - -func (cook XvQueryAdaptorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryAdaptors -func (c *Conn) xvQueryAdaptorsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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 XvQueryEncodings -// size: 8 -type XvQueryEncodingsCookie struct { - *cookie -} - -func (c *Conn) XvQueryEncodings(Port XvPort) XvQueryEncodingsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryEncodingsRequest(Port), cookie) - return XvQueryEncodingsCookie{cookie} -} - -func (c *Conn) XvQueryEncodingsUnchecked(Port XvPort) XvQueryEncodingsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryEncodingsRequest(Port), cookie) - return XvQueryEncodingsCookie{cookie} -} - -// Request reply for XvQueryEncodings -// size: (32 + XvEncodingInfoListSize(Info)) -type XvQueryEncodingsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumEncodings uint16 - // padding: 22 bytes - Info []XvEncodingInfo // size: XvEncodingInfoListSize(Info) -} - -// Waits and reads reply data from request XvQueryEncodings -func (cook XvQueryEncodingsCookie) Reply() (*XvQueryEncodingsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryEncodingsReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryEncodings -func xvQueryEncodingsReply(buf []byte) *XvQueryEncodingsReply { - v := new(XvQueryEncodingsReply) - 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.NumEncodings = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]XvEncodingInfo, v.NumEncodings) - b += ReadXvEncodingInfoList(buf[b:], v.Info) - - return v -} - -func (cook XvQueryEncodingsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryEncodings -func (c *Conn) xvQueryEncodingsRequest(Port XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - return buf -} - -// Request XvGrabPort -// size: 12 -type XvGrabPortCookie struct { - *cookie -} - -func (c *Conn) XvGrabPort(Port XvPort, Time Timestamp) XvGrabPortCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvGrabPortRequest(Port, Time), cookie) - return XvGrabPortCookie{cookie} -} - -func (c *Conn) XvGrabPortUnchecked(Port XvPort, Time Timestamp) XvGrabPortCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvGrabPortRequest(Port, Time), cookie) - return XvGrabPortCookie{cookie} -} - -// Request reply for XvGrabPort -// size: 8 -type XvGrabPortReply struct { - Sequence uint16 - Length uint32 - Result byte -} - -// Waits and reads reply data from request XvGrabPort -func (cook XvGrabPortCookie) Reply() (*XvGrabPortReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvGrabPortReply(buf), nil -} - -// Read reply into structure from buffer for XvGrabPort -func xvGrabPortReply(buf []byte) *XvGrabPortReply { - v := new(XvGrabPortReply) - b := 1 // skip reply determinant - - v.Result = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook XvGrabPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGrabPort -func (c *Conn) xvGrabPortRequest(Port XvPort, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request XvUngrabPort -// size: 12 -type XvUngrabPortCookie struct { - *cookie -} - -// Write request to wire for XvUngrabPort -func (c *Conn) XvUngrabPort(Port XvPort, Time Timestamp) XvUngrabPortCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvUngrabPortRequest(Port, Time), cookie) - return XvUngrabPortCookie{cookie} -} - -func (c *Conn) XvUngrabPortChecked(Port XvPort, Time Timestamp) XvUngrabPortCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvUngrabPortRequest(Port, Time), cookie) - return XvUngrabPortCookie{cookie} -} - -func (cook XvUngrabPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvUngrabPort -func (c *Conn) xvUngrabPortRequest(Port XvPort, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request XvPutVideo -// size: 32 -type XvPutVideoCookie struct { - *cookie -} - -// Write request to wire for XvPutVideo -func (c *Conn) XvPutVideo(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutVideoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvPutVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutVideoCookie{cookie} -} - -func (c *Conn) XvPutVideoChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutVideoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvPutVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutVideoCookie{cookie} -} - -func (cook XvPutVideoCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvPutVideo -func (c *Conn) xvPutVideoRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvPutStill -// size: 32 -type XvPutStillCookie struct { - *cookie -} - -// Write request to wire for XvPutStill -func (c *Conn) XvPutStill(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutStillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvPutStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutStillCookie{cookie} -} - -func (c *Conn) XvPutStillChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutStillCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvPutStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutStillCookie{cookie} -} - -func (cook XvPutStillCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvPutStill -func (c *Conn) xvPutStillRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvGetVideo -// size: 32 -type XvGetVideoCookie struct { - *cookie -} - -// Write request to wire for XvGetVideo -func (c *Conn) XvGetVideo(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetVideoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvGetVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetVideoCookie{cookie} -} - -func (c *Conn) XvGetVideoChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetVideoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvGetVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetVideoCookie{cookie} -} - -func (cook XvGetVideoCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGetVideo -func (c *Conn) xvGetVideoRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvGetStill -// size: 32 -type XvGetStillCookie struct { - *cookie -} - -// Write request to wire for XvGetStill -func (c *Conn) XvGetStill(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetStillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvGetStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetStillCookie{cookie} -} - -func (c *Conn) XvGetStillChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetStillCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvGetStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetStillCookie{cookie} -} - -func (cook XvGetStillCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGetStill -func (c *Conn) xvGetStillRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - 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(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvStopVideo -// size: 12 -type XvStopVideoCookie struct { - *cookie -} - -// Write request to wire for XvStopVideo -func (c *Conn) XvStopVideo(Port XvPort, Drawable Drawable) XvStopVideoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvStopVideoRequest(Port, Drawable), cookie) - return XvStopVideoCookie{cookie} -} - -func (c *Conn) XvStopVideoChecked(Port XvPort, Drawable Drawable) XvStopVideoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvStopVideoRequest(Port, Drawable), cookie) - return XvStopVideoCookie{cookie} -} - -func (cook XvStopVideoCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvStopVideo -func (c *Conn) xvStopVideoRequest(Port XvPort, Drawable Drawable) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request XvSelectVideoNotify -// size: 12 -type XvSelectVideoNotifyCookie struct { - *cookie -} - -// Write request to wire for XvSelectVideoNotify -func (c *Conn) XvSelectVideoNotify(Drawable Drawable, Onoff bool) XvSelectVideoNotifyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvSelectVideoNotifyRequest(Drawable, Onoff), cookie) - return XvSelectVideoNotifyCookie{cookie} -} - -func (c *Conn) XvSelectVideoNotifyChecked(Drawable Drawable, Onoff bool) XvSelectVideoNotifyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvSelectVideoNotifyRequest(Drawable, Onoff), cookie) - return XvSelectVideoNotifyCookie{cookie} -} - -func (cook XvSelectVideoNotifyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvSelectVideoNotify -func (c *Conn) xvSelectVideoNotifyRequest(Drawable Drawable, Onoff bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 10 // 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 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XvSelectPortNotify -// size: 12 -type XvSelectPortNotifyCookie struct { - *cookie -} - -// Write request to wire for XvSelectPortNotify -func (c *Conn) XvSelectPortNotify(Port XvPort, Onoff bool) XvSelectPortNotifyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvSelectPortNotifyRequest(Port, Onoff), cookie) - return XvSelectPortNotifyCookie{cookie} -} - -func (c *Conn) XvSelectPortNotifyChecked(Port XvPort, Onoff bool) XvSelectPortNotifyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvSelectPortNotifyRequest(Port, Onoff), cookie) - return XvSelectPortNotifyCookie{cookie} -} - -func (cook XvSelectPortNotifyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvSelectPortNotify -func (c *Conn) xvSelectPortNotifyRequest(Port XvPort, Onoff bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XvQueryBestSize -// size: 20 -type XvQueryBestSizeCookie struct { - *cookie -} - -func (c *Conn) XvQueryBestSize(Port XvPort, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) XvQueryBestSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryBestSizeRequest(Port, VidW, VidH, DrwW, DrwH, Motion), cookie) - return XvQueryBestSizeCookie{cookie} -} - -func (c *Conn) XvQueryBestSizeUnchecked(Port XvPort, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) XvQueryBestSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryBestSizeRequest(Port, VidW, VidH, DrwW, DrwH, Motion), cookie) - return XvQueryBestSizeCookie{cookie} -} - -// Request reply for XvQueryBestSize -// size: 12 -type XvQueryBestSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ActualWidth uint16 - ActualHeight uint16 -} - -// Waits and reads reply data from request XvQueryBestSize -func (cook XvQueryBestSizeCookie) Reply() (*XvQueryBestSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryBestSizeReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryBestSize -func xvQueryBestSizeReply(buf []byte) *XvQueryBestSizeReply { - v := new(XvQueryBestSizeReply) - 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.ActualWidth = Get16(buf[b:]) - b += 2 - - v.ActualHeight = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XvQueryBestSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryBestSize -func (c *Conn) xvQueryBestSizeRequest(Port XvPort, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - if Motion { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XvSetPortAttribute -// size: 16 -type XvSetPortAttributeCookie struct { - *cookie -} - -// Write request to wire for XvSetPortAttribute -func (c *Conn) XvSetPortAttribute(Port XvPort, Attribute Atom, Value int32) XvSetPortAttributeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvSetPortAttributeRequest(Port, Attribute, Value), cookie) - return XvSetPortAttributeCookie{cookie} -} - -func (c *Conn) XvSetPortAttributeChecked(Port XvPort, Attribute Atom, Value int32) XvSetPortAttributeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvSetPortAttributeRequest(Port, Attribute, Value), cookie) - return XvSetPortAttributeCookie{cookie} -} - -func (cook XvSetPortAttributeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvSetPortAttribute -func (c *Conn) xvSetPortAttributeRequest(Port XvPort, Attribute Atom, Value int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Attribute)) - b += 4 - - Put32(buf[b:], uint32(Value)) - b += 4 - - return buf -} - -// Request XvGetPortAttribute -// size: 12 -type XvGetPortAttributeCookie struct { - *cookie -} - -func (c *Conn) XvGetPortAttribute(Port XvPort, Attribute Atom) XvGetPortAttributeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvGetPortAttributeRequest(Port, Attribute), cookie) - return XvGetPortAttributeCookie{cookie} -} - -func (c *Conn) XvGetPortAttributeUnchecked(Port XvPort, Attribute Atom) XvGetPortAttributeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvGetPortAttributeRequest(Port, Attribute), cookie) - return XvGetPortAttributeCookie{cookie} -} - -// Request reply for XvGetPortAttribute -// size: 12 -type XvGetPortAttributeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Value int32 -} - -// Waits and reads reply data from request XvGetPortAttribute -func (cook XvGetPortAttributeCookie) Reply() (*XvGetPortAttributeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvGetPortAttributeReply(buf), nil -} - -// Read reply into structure from buffer for XvGetPortAttribute -func xvGetPortAttributeReply(buf []byte) *XvGetPortAttributeReply { - v := new(XvGetPortAttributeReply) - 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.Value = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook XvGetPortAttributeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGetPortAttribute -func (c *Conn) xvGetPortAttributeRequest(Port XvPort, Attribute Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Attribute)) - b += 4 - - return buf -} - -// Request XvQueryPortAttributes -// size: 8 -type XvQueryPortAttributesCookie struct { - *cookie -} - -func (c *Conn) XvQueryPortAttributes(Port XvPort) XvQueryPortAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryPortAttributesRequest(Port), cookie) - return XvQueryPortAttributesCookie{cookie} -} - -func (c *Conn) XvQueryPortAttributesUnchecked(Port XvPort) XvQueryPortAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryPortAttributesRequest(Port), cookie) - return XvQueryPortAttributesCookie{cookie} -} - -// Request reply for XvQueryPortAttributes -// size: (32 + XvAttributeInfoListSize(Attributes)) -type XvQueryPortAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAttributes uint32 - TextSize uint32 - // padding: 16 bytes - Attributes []XvAttributeInfo // size: XvAttributeInfoListSize(Attributes) -} - -// Waits and reads reply data from request XvQueryPortAttributes -func (cook XvQueryPortAttributesCookie) Reply() (*XvQueryPortAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryPortAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryPortAttributes -func xvQueryPortAttributesReply(buf []byte) *XvQueryPortAttributesReply { - v := new(XvQueryPortAttributesReply) - 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.NumAttributes = Get32(buf[b:]) - b += 4 - - v.TextSize = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.Attributes = make([]XvAttributeInfo, v.NumAttributes) - b += ReadXvAttributeInfoList(buf[b:], v.Attributes) - - return v -} - -func (cook XvQueryPortAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryPortAttributes -func (c *Conn) xvQueryPortAttributesRequest(Port XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - return buf -} - -// Request XvListImageFormats -// size: 8 -type XvListImageFormatsCookie struct { - *cookie -} - -func (c *Conn) XvListImageFormats(Port XvPort) XvListImageFormatsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvListImageFormatsRequest(Port), cookie) - return XvListImageFormatsCookie{cookie} -} - -func (c *Conn) XvListImageFormatsUnchecked(Port XvPort) XvListImageFormatsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvListImageFormatsRequest(Port), cookie) - return XvListImageFormatsCookie{cookie} -} - -// Request reply for XvListImageFormats -// size: (32 + XvImageFormatInfoListSize(Format)) -type XvListImageFormatsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFormats uint32 - // padding: 20 bytes - Format []XvImageFormatInfo // size: XvImageFormatInfoListSize(Format) -} - -// Waits and reads reply data from request XvListImageFormats -func (cook XvListImageFormatsCookie) Reply() (*XvListImageFormatsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvListImageFormatsReply(buf), nil -} - -// Read reply into structure from buffer for XvListImageFormats -func xvListImageFormatsReply(buf []byte) *XvListImageFormatsReply { - v := new(XvListImageFormatsReply) - 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.NumFormats = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Format = make([]XvImageFormatInfo, v.NumFormats) - b += ReadXvImageFormatInfoList(buf[b:], v.Format) - - return v -} - -func (cook XvListImageFormatsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvListImageFormats -func (c *Conn) xvListImageFormatsRequest(Port XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - return buf -} - -// Request XvQueryImageAttributes -// size: 16 -type XvQueryImageAttributesCookie struct { - *cookie -} - -func (c *Conn) XvQueryImageAttributes(Port XvPort, Id uint32, Width uint16, Height uint16) XvQueryImageAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryImageAttributesRequest(Port, Id, Width, Height), cookie) - return XvQueryImageAttributesCookie{cookie} -} - -func (c *Conn) XvQueryImageAttributesUnchecked(Port XvPort, Id uint32, Width uint16, Height uint16) XvQueryImageAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryImageAttributesRequest(Port, Id, Width, Height), cookie) - return XvQueryImageAttributesCookie{cookie} -} - -// Request reply for XvQueryImageAttributes -// size: ((32 + pad((int(NumPlanes) * 4))) + pad((int(NumPlanes) * 4))) -type XvQueryImageAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumPlanes uint32 - DataSize uint32 - Width uint16 - Height uint16 - // padding: 12 bytes - Pitches []uint32 // size: pad((int(NumPlanes) * 4)) - Offsets []uint32 // size: pad((int(NumPlanes) * 4)) -} - -// Waits and reads reply data from request XvQueryImageAttributes -func (cook XvQueryImageAttributesCookie) Reply() (*XvQueryImageAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryImageAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryImageAttributes -func xvQueryImageAttributesReply(buf []byte) *XvQueryImageAttributesReply { - v := new(XvQueryImageAttributesReply) - 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.NumPlanes = Get32(buf[b:]) - b += 4 - - v.DataSize = Get32(buf[b:]) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - b += 12 // padding - - v.Pitches = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Pitches[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Offsets = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Offsets[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XvQueryImageAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryImageAttributes -func (c *Conn) xvQueryImageAttributesRequest(Port XvPort, Id uint32, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request XvPutImage -// size: pad((40 + pad((len(Data) * 1)))) -type XvPutImageCookie struct { - *cookie -} - -// Write request to wire for XvPutImage -func (c *Conn) XvPutImage(Port XvPort, Drawable Drawable, Gc Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) XvPutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvPutImageRequest(Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return XvPutImageCookie{cookie} -} - -func (c *Conn) XvPutImageChecked(Port XvPort, Drawable Drawable, Gc Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) XvPutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvPutImageRequest(Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return XvPutImageCookie{cookie} -} - -func (cook XvPutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvPutImage -func (c *Conn) xvPutImageRequest(Port XvPort, Drawable Drawable, Gc Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { - size := pad((40 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], SrcW) - b += 2 - - Put16(buf[b:], SrcH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request XvShmPutImage -// size: 52 -type XvShmPutImageCookie struct { - *cookie -} - -// Write request to wire for XvShmPutImage -func (c *Conn) XvShmPutImage(Port XvPort, Drawable Drawable, Gc Gcontext, Shmseg ShmSeg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) XvShmPutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvShmPutImageRequest(Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) - return XvShmPutImageCookie{cookie} -} - -func (c *Conn) XvShmPutImageChecked(Port XvPort, Drawable Drawable, Gc Gcontext, Shmseg ShmSeg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) XvShmPutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvShmPutImageRequest(Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) - return XvShmPutImageCookie{cookie} -} - -func (cook XvShmPutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvShmPutImage -func (c *Conn) xvShmPutImageRequest(Port XvPort, Drawable Drawable, Gc Gcontext, Shmseg ShmSeg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { - size := 52 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], Offset) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], SrcW) - b += 2 - - Put16(buf[b:], SrcH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - buf[b] = SendEvent - b += 1 - - b += 3 // padding - - return buf -} diff --git a/nexgb/auto_xvmc.go b/nexgb/auto_xvmc.go deleted file mode 100644 index ba4bd44..0000000 --- a/nexgb/auto_xvmc.go +++ /dev/null @@ -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 -} diff --git a/nexgb/bigreq/bigreq.go b/nexgb/bigreq/bigreq.go new file mode 100644 index 0000000..8bb05c1 --- /dev/null +++ b/nexgb/bigreq/bigreq.go @@ -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 +} diff --git a/nexgb/composite/composite.go b/nexgb/composite/composite.go new file mode 100644 index 0000000..266c087 --- /dev/null +++ b/nexgb/composite/composite.go @@ -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 +} diff --git a/nexgb/conn.go b/nexgb/conn.go index af78be9..662a059 100644 --- a/nexgb/conn.go +++ b/nexgb/conn.go @@ -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) } diff --git a/nexgb/cookie.go b/nexgb/cookie.go index 8c0774d..0f32990 100644 --- a/nexgb/cookie.go +++ b/nexgb/cookie.go @@ -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 diff --git a/nexgb/damage/damage.go b/nexgb/damage/damage.go new file mode 100644 index 0000000..8fe1e38 --- /dev/null +++ b/nexgb/damage/damage.go @@ -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 +} diff --git a/nexgb/doc.go b/nexgb/doc.go index b6c956f..91c6406 100644 --- a/nexgb/doc.go +++ b/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) } diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go new file mode 100644 index 0000000..01314ac --- /dev/null +++ b/nexgb/dpms/dpms.go @@ -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 +} diff --git a/nexgb/dri2/dri2.go b/nexgb/dri2/dri2.go new file mode 100644 index 0000000..cffe20e --- /dev/null +++ b/nexgb/dri2/dri2.go @@ -0,0 +1,1522 @@ +package dri2 + +/* + This file was generated by dri2.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 DRI2 extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 4, "DRI2").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named DRI2 could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["DRI2"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["DRI2"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["DRI2"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["DRI2"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["DRI2"] = 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 ( + AttachmentBufferFrontLeft = 0 + AttachmentBufferBackLeft = 1 + AttachmentBufferFrontRight = 2 + AttachmentBufferBackRight = 3 + AttachmentBufferDepth = 4 + AttachmentBufferStencil = 5 + AttachmentBufferAccum = 6 + AttachmentBufferFakeFrontLeft = 7 + AttachmentBufferFakeFrontRight = 8 + AttachmentBufferDepthStencil = 9 + AttachmentBufferHiz = 10 +) + +const ( + DriverTypeDri = 0 + DriverTypeVdpau = 1 +) + +const ( + EventTypeExchangeComplete = 1 + EventTypeBlitComplete = 2 + EventTypeFlipComplete = 3 +) + +// 'DRI2Buffer' struct definition +// Size: 20 +type DRI2Buffer struct { + Attachment uint32 + Name uint32 + Pitch uint32 + Cpp uint32 + Flags uint32 +} + +// Struct read DRI2Buffer +func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { + b := 0 + + v.Attachment = xgb.Get32(buf[b:]) + b += 4 + + v.Name = xgb.Get32(buf[b:]) + b += 4 + + v.Pitch = xgb.Get32(buf[b:]) + b += 4 + + v.Cpp = xgb.Get32(buf[b:]) + b += 4 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DRI2Buffer +func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DRI2Buffer{} + b += DRI2BufferRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DRI2Buffer +func (v DRI2Buffer) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + xgb.Put32(buf[b:], v.Attachment) + b += 4 + + xgb.Put32(buf[b:], v.Name) + b += 4 + + xgb.Put32(buf[b:], v.Pitch) + b += 4 + + xgb.Put32(buf[b:], v.Cpp) + b += 4 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + return buf +} + +// Write struct list DRI2Buffer +func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AttachFormat' struct definition +// Size: 8 +type AttachFormat struct { + Attachment uint32 + Format uint32 +} + +// Struct read AttachFormat +func AttachFormatRead(buf []byte, v *AttachFormat) int { + b := 0 + + v.Attachment = xgb.Get32(buf[b:]) + b += 4 + + v.Format = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read AttachFormat +func AttachFormatReadList(buf []byte, dest []AttachFormat) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AttachFormat{} + b += AttachFormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AttachFormat +func (v AttachFormat) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], v.Attachment) + b += 4 + + xgb.Put32(buf[b:], v.Format) + b += 4 + + return buf +} + +// Write struct list AttachFormat +func AttachFormatListBytes(buf []byte, list []AttachFormat) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Event definition BufferSwapComplete (0) +// Size: 32 + +const BufferSwapComplete = 0 + +type BufferSwapCompleteEvent struct { + Sequence uint16 + // padding: 1 bytes + EventType uint16 + // padding: 2 bytes + Drawable xproto.Drawable + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + Sbc uint32 +} + +// Event read BufferSwapComplete +func BufferSwapCompleteEventNew(buf []byte) xgb.Event { + v := BufferSwapCompleteEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.EventType = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.Sbc = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Event write BufferSwapComplete +func (v BufferSwapCompleteEvent) 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.Put16(buf[b:], v.EventType) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], v.UstHi) + b += 4 + + xgb.Put32(buf[b:], v.UstLo) + b += 4 + + xgb.Put32(buf[b:], v.MscHi) + b += 4 + + xgb.Put32(buf[b:], v.MscLo) + b += 4 + + xgb.Put32(buf[b:], v.Sbc) + b += 4 + + return buf +} + +func (v BufferSwapCompleteEvent) ImplementsEvent() {} + +func (v BufferSwapCompleteEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v BufferSwapCompleteEvent) String() string { + fieldVals := make([]string, 0, 9) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("EventType: %d", v.EventType)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("UstHi: %d", v.UstHi)) + fieldVals = append(fieldVals, xgb.Sprintf("UstLo: %d", v.UstLo)) + fieldVals = append(fieldVals, xgb.Sprintf("MscHi: %d", v.MscHi)) + fieldVals = append(fieldVals, xgb.Sprintf("MscLo: %d", v.MscLo)) + fieldVals = append(fieldVals, xgb.Sprintf("Sbc: %d", v.Sbc)) + return "BufferSwapComplete {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["DRI2"][0] = BufferSwapCompleteEventNew +} + +// Event definition InvalidateBuffers (1) +// Size: 32 + +const InvalidateBuffers = 1 + +type InvalidateBuffersEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable xproto.Drawable +} + +// Event read InvalidateBuffers +func InvalidateBuffersEventNew(buf []byte) xgb.Event { + v := InvalidateBuffersEvent{} + 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 + + return v +} + +// Event write InvalidateBuffers +func (v InvalidateBuffersEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + return buf +} + +func (v InvalidateBuffersEvent) ImplementsEvent() {} + +func (v InvalidateBuffersEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v InvalidateBuffersEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + return "InvalidateBuffers {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["DRI2"][1] = InvalidateBuffersEventNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 16 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion 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.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// Request Connect +// size: 12 +type ConnectCookie struct { + *xgb.Cookie +} + +func Connect(c *xgb.Conn, Window xproto.Window, DriverType uint32) ConnectCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(connectRequest(c, Window, DriverType), cookie) + return ConnectCookie{cookie} +} + +func ConnectUnchecked(c *xgb.Conn, Window xproto.Window, DriverType uint32) ConnectCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(connectRequest(c, Window, DriverType), cookie) + return ConnectCookie{cookie} +} + +// Request reply for Connect +// size: (((32 + xgb.Pad((int(DriverNameLength) * 1))) + xgb.Pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1))) + xgb.Pad((int(DeviceNameLength) * 1))) +type ConnectReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DriverNameLength uint32 + DeviceNameLength uint32 + // padding: 16 bytes + DriverName string // size: xgb.Pad((int(DriverNameLength) * 1)) + AlignmentPad []byte // size: xgb.Pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1)) + DeviceName string // size: xgb.Pad((int(DeviceNameLength) * 1)) +} + +// Waits and reads reply data from request Connect +func (cook ConnectCookie) Reply() (*ConnectReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return connectReply(buf), nil +} + +// Read reply into structure from buffer for Connect +func connectReply(buf []byte) *ConnectReply { + v := new(ConnectReply) + 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.DriverNameLength = xgb.Get32(buf[b:]) + b += 4 + + v.DeviceNameLength = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + { + byteString := make([]byte, v.DriverNameLength) + copy(byteString[:v.DriverNameLength], buf[b:]) + v.DriverName = string(byteString) + b += xgb.Pad(int(v.DriverNameLength)) + } + + v.AlignmentPad = make([]byte, (((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength))) + copy(v.AlignmentPad[:(((int(v.DriverNameLength)+3)&-4)-int(v.DriverNameLength))], buf[b:]) + b += xgb.Pad(int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))) + + { + byteString := make([]byte, v.DeviceNameLength) + copy(byteString[:v.DeviceNameLength], buf[b:]) + v.DeviceName = string(byteString) + b += xgb.Pad(int(v.DeviceNameLength)) + } + + return v +} + +// Write request to wire for Connect +func connectRequest(c *xgb.Conn, Window xproto.Window, DriverType uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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:], DriverType) + b += 4 + + return buf +} + +// Request Authenticate +// size: 12 +type AuthenticateCookie struct { + *xgb.Cookie +} + +func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} +} + +func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} +} + +// Request reply for Authenticate +// size: 12 +type AuthenticateReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Authenticated uint32 +} + +// Waits and reads reply data from request Authenticate +func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return authenticateReply(buf), nil +} + +// Read reply into structure from buffer for Authenticate +func authenticateReply(buf []byte) *AuthenticateReply { + v := new(AuthenticateReply) + 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.Authenticated = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for Authenticate +func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], Magic) + b += 4 + + return buf +} + +// Request CreateDrawable +// size: 8 +type CreateDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateDrawable +func CreateDrawable(c *xgb.Conn, Drawable xproto.Drawable) CreateDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createDrawableRequest(c, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func CreateDrawableChecked(c *xgb.Conn, Drawable xproto.Drawable) CreateDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createDrawableRequest(c, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func (cook CreateDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateDrawable +func createDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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 + + return buf +} + +// Request DestroyDrawable +// size: 8 +type DestroyDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyDrawable +func DestroyDrawable(c *xgb.Conn, Drawable xproto.Drawable) DestroyDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyDrawableRequest(c, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func DestroyDrawableChecked(c *xgb.Conn, Drawable xproto.Drawable) DestroyDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyDrawableRequest(c, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func (cook DestroyDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyDrawable +func destroyDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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 GetBuffers +// size: xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) +type GetBuffersCookie struct { + *xgb.Cookie +} + +func GetBuffers(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) GetBuffersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getBuffersRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersCookie{cookie} +} + +func GetBuffersUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) GetBuffersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getBuffersRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersCookie{cookie} +} + +// Request reply for GetBuffers +// size: (32 + xgb.Pad((int(Count) * 20))) +type GetBuffersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint32 + Height uint32 + Count uint32 + // padding: 12 bytes + Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) +} + +// Waits and reads reply data from request GetBuffers +func (cook GetBuffersCookie) Reply() (*GetBuffersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBuffersReply(buf), nil +} + +// Read reply into structure from buffer for GetBuffers +func getBuffersReply(buf []byte) *GetBuffersReply { + v := new(GetBuffersReply) + 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.Count = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Buffers = make([]DRI2Buffer, v.Count) + b += DRI2BufferReadList(buf[b:], v.Buffers) + + return v +} + +// Write request to wire for GetBuffers +func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + for i := 0; i < int(len(Attachments)); i++ { + xgb.Put32(buf[b:], Attachments[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CopyRegion +// size: 20 +type CopyRegionCookie struct { + *xgb.Cookie +} + +func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} +} + +func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} +} + +// Request reply for CopyRegion +// size: 8 +type CopyRegionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes +} + +// Waits and reads reply data from request CopyRegion +func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return copyRegionReply(buf), nil +} + +// Read reply into structure from buffer for CopyRegion +func copyRegionReply(buf []byte) *CopyRegionReply { + v := new(CopyRegionReply) + 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 + + return v +} + +// Write request to wire for CopyRegion +func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Region) + b += 4 + + xgb.Put32(buf[b:], Dest) + b += 4 + + xgb.Put32(buf[b:], Src) + b += 4 + + return buf +} + +// Request GetBuffersWithFormat +// size: xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) +type GetBuffersWithFormatCookie struct { + *xgb.Cookie +} + +func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} +} + +func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} +} + +// Request reply for GetBuffersWithFormat +// size: (32 + xgb.Pad((int(Count) * 20))) +type GetBuffersWithFormatReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint32 + Height uint32 + Count uint32 + // padding: 12 bytes + Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) +} + +// Waits and reads reply data from request GetBuffersWithFormat +func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBuffersWithFormatReply(buf), nil +} + +// Read reply into structure from buffer for GetBuffersWithFormat +func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { + v := new(GetBuffersWithFormatReply) + 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.Count = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Buffers = make([]DRI2Buffer, v.Count) + b += DRI2BufferReadList(buf[b:], v.Buffers) + + return v +} + +// Write request to wire for GetBuffersWithFormat +func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + b += AttachFormatListBytes(buf[b:], Attachments) + + return buf +} + +// Request SwapBuffers +// size: 32 +type SwapBuffersCookie struct { + *xgb.Cookie +} + +func SwapBuffers(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) SwapBuffersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(swapBuffersRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return SwapBuffersCookie{cookie} +} + +func SwapBuffersUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) SwapBuffersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(swapBuffersRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return SwapBuffersCookie{cookie} +} + +// Request reply for SwapBuffers +// size: 16 +type SwapBuffersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SwapHi uint32 + SwapLo uint32 +} + +// Waits and reads reply data from request SwapBuffers +func (cook SwapBuffersCookie) Reply() (*SwapBuffersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return swapBuffersReply(buf), nil +} + +// Read reply into structure from buffer for SwapBuffers +func swapBuffersReply(buf []byte) *SwapBuffersReply { + v := new(SwapBuffersReply) + 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.SwapHi = xgb.Get32(buf[b:]) + b += 4 + + v.SwapLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for SwapBuffers +func swapBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], TargetMscHi) + b += 4 + + xgb.Put32(buf[b:], TargetMscLo) + b += 4 + + xgb.Put32(buf[b:], DivisorHi) + b += 4 + + xgb.Put32(buf[b:], DivisorLo) + b += 4 + + xgb.Put32(buf[b:], RemainderHi) + b += 4 + + xgb.Put32(buf[b:], RemainderLo) + b += 4 + + return buf +} + +// Request GetMSC +// size: 8 +type GetMSCCookie struct { + *xgb.Cookie +} + +func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} +} + +func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} +} + +// Request reply for GetMSC +// size: 32 +type GetMSCReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Waits and reads reply data from request GetMSC +func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMSCReply(buf), nil +} + +// Read reply into structure from buffer for GetMSC +func getMSCReply(buf []byte) *GetMSCReply { + v := new(GetMSCReply) + 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.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetMSC +func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request WaitMSC +// size: 32 +type WaitMSCCookie struct { + *xgb.Cookie +} + +func WaitMSC(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) WaitMSCCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(waitMSCRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return WaitMSCCookie{cookie} +} + +func WaitMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) WaitMSCCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(waitMSCRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return WaitMSCCookie{cookie} +} + +// Request reply for WaitMSC +// size: 32 +type WaitMSCReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Waits and reads reply data from request WaitMSC +func (cook WaitMSCCookie) Reply() (*WaitMSCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return waitMSCReply(buf), nil +} + +// Read reply into structure from buffer for WaitMSC +func waitMSCReply(buf []byte) *WaitMSCReply { + v := new(WaitMSCReply) + 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.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for WaitMSC +func waitMSCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], TargetMscHi) + b += 4 + + xgb.Put32(buf[b:], TargetMscLo) + b += 4 + + xgb.Put32(buf[b:], DivisorHi) + b += 4 + + xgb.Put32(buf[b:], DivisorLo) + b += 4 + + xgb.Put32(buf[b:], RemainderHi) + b += 4 + + xgb.Put32(buf[b:], RemainderLo) + b += 4 + + return buf +} + +// Request WaitSBC +// size: 16 +type WaitSBCCookie struct { + *xgb.Cookie +} + +func WaitSBC(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) WaitSBCCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(waitSBCRequest(c, Drawable, TargetSbcHi, TargetSbcLo), cookie) + return WaitSBCCookie{cookie} +} + +func WaitSBCUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) WaitSBCCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(waitSBCRequest(c, Drawable, TargetSbcHi, TargetSbcLo), cookie) + return WaitSBCCookie{cookie} +} + +// Request reply for WaitSBC +// size: 32 +type WaitSBCReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Waits and reads reply data from request WaitSBC +func (cook WaitSBCCookie) Reply() (*WaitSBCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return waitSBCReply(buf), nil +} + +// Read reply into structure from buffer for WaitSBC +func waitSBCReply(buf []byte) *WaitSBCReply { + v := new(WaitSBCReply) + 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.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for WaitSBC +func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], TargetSbcHi) + b += 4 + + xgb.Put32(buf[b:], TargetSbcLo) + b += 4 + + return buf +} + +// Request SwapInterval +// size: 12 +type SwapIntervalCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwapInterval +func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} +} + +func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} +} + +func (cook SwapIntervalCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwapInterval +func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Interval) + b += 4 + + return buf +} diff --git a/nexgb/examples/create-window/main.go b/nexgb/examples/create-window/main.go index 6996f37..73a0099 100644 --- a/nexgb/examples/create-window/main.go +++ b/nexgb/examples/create-window/main.go @@ -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 diff --git a/nexgb/examples/get-active-window/main.go b/nexgb/examples/get-active-window/main.go index e90563c..48e020c 100644 --- a/nexgb/examples/get-active-window/main.go +++ b/nexgb/examples/get-active-window/main.go @@ -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) } diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go index 5c56609..ad575ee 100644 --- a/nexgb/examples/randr/main.go +++ b/nexgb/examples/randr/main.go @@ -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) } diff --git a/nexgb/examples/xinerama/main.go b/nexgb/examples/xinerama/main.go index ec7f46a..896bb63 100644 --- a/nexgb/examples/xinerama/main.go +++ b/nexgb/examples/xinerama/main.go @@ -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) } diff --git a/nexgb/ge/ge.go b/nexgb/ge/ge.go new file mode 100644 index 0000000..7753e28 --- /dev/null +++ b/nexgb/ge/ge.go @@ -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 +} diff --git a/nexgb/glx/glx.go b/nexgb/glx/glx.go new file mode 100644 index 0000000..0aa2e55 --- /dev/null +++ b/nexgb/glx/glx.go @@ -0,0 +1,9168 @@ +package glx + +/* + This file was generated by glx.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 GLX extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 3, "GLX").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named GLX could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["GLX"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["GLX"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["GLX"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["GLX"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["GLX"] = 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 ( + PbcetDamaged = 32791 + PbcetSaved = 32792 +) + +const ( + PbcdtWindow = 32793 + PbcdtPbuffer = 32794 +) + +const ( + GcGlCurrentBit = 1 + GcGlPointBit = 2 + GcGlLineBit = 4 + GcGlPolygonBit = 8 + GcGlPolygonStippleBit = 16 + GcGlPixelModeBit = 32 + GcGlLightingBit = 64 + GcGlFogBit = 128 + GcGlDepthBufferBit = 256 + GcGlAccumBufferBit = 512 + GcGlStencilBufferBit = 1024 + GcGlViewportBit = 2048 + GcGlTransformBit = 4096 + GcGlEnableBit = 8192 + GcGlColorBufferBit = 16384 + GcGlHintBit = 32768 + GcGlEvalBit = 65536 + GcGlListBit = 131072 + GcGlTextureBit = 262144 + GcGlScissorBit = 524288 + GcGlAllAttribBits = 16777215 +) + +const ( + RmGlRender = 7168 + RmGlFeedback = 7169 + RmGlSelect = 7170 +) + +type Pixmap uint32 + +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} + +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 Pbuffer uint32 + +func NewPbufferId(c *xgb.Conn) (Pbuffer, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pbuffer(id), nil +} + +type Window uint32 + +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} + +type Fbconfig uint32 + +func NewFbconfigId(c *xgb.Conn) (Fbconfig, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fbconfig(id), nil +} + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +type Float32 float64 + +type Float64 float64 + +type Bool32 uint32 + +type ContextTag uint32 + +// Event definition PbufferClobber (0) +// Size: 32 + +const PbufferClobber = 0 + +type PbufferClobberEvent struct { + Sequence uint16 + // padding: 1 bytes + EventType uint16 + DrawType uint16 + Drawable Drawable + BMask uint32 + AuxBuffer uint16 + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 4 bytes +} + +// Event read PbufferClobber +func PbufferClobberEventNew(buf []byte) xgb.Event { + v := PbufferClobberEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.EventType = xgb.Get16(buf[b:]) + b += 2 + + v.DrawType = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.BMask = xgb.Get32(buf[b:]) + b += 4 + + v.AuxBuffer = xgb.Get16(buf[b:]) + b += 2 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + return v +} + +// Event write PbufferClobber +func (v PbufferClobberEvent) 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.Put16(buf[b:], v.EventType) + b += 2 + + xgb.Put16(buf[b:], v.DrawType) + b += 2 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], v.BMask) + b += 4 + + xgb.Put16(buf[b:], v.AuxBuffer) + b += 2 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + b += 4 // padding + + return buf +} + +func (v PbufferClobberEvent) ImplementsEvent() {} + +func (v PbufferClobberEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PbufferClobberEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("EventType: %d", v.EventType)) + fieldVals = append(fieldVals, xgb.Sprintf("DrawType: %d", v.DrawType)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("BMask: %d", v.BMask)) + fieldVals = append(fieldVals, xgb.Sprintf("AuxBuffer: %d", v.AuxBuffer)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "PbufferClobber {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["GLX"][0] = PbufferClobberEventNew +} + +// Error definition Generic (-1) +// Size: 32 + +const BadGeneric = -1 + +type GenericError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 21 bytes +} + +// Error read Generic +func GenericErrorNew(buf []byte) xgb.Error { + v := GenericError{} + v.NiceName = "Generic" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 21 // padding + + return v +} + +func (err GenericError) ImplementsError() {} + +func (err GenericError) SequenceId() uint16 { + return err.Sequence +} + +func (err GenericError) BadId() uint32 { + return 0 +} + +func (err GenericError) 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 "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew +} + +// ErrorCopy definition BadContext (0) + +const BadBadContext = 0 + +type BadContextError GenericError + +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContext" + return v +} + +func (err BadContextError) ImplementsError() {} + +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextError) BadId() uint32 { + return 0 +} + +func (err BadContextError) 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 "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][0] = BadContextErrorNew +} + +// ErrorCopy definition BadContextState (1) + +const BadBadContextState = 1 + +type BadContextStateError GenericError + +func BadContextStateErrorNew(buf []byte) xgb.Error { + v := BadContextStateError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContextState" + return v +} + +func (err BadContextStateError) ImplementsError() {} + +func (err BadContextStateError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextStateError) BadId() uint32 { + return 0 +} + +func (err BadContextStateError) 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 "BadBadContextState {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][1] = BadContextStateErrorNew +} + +// ErrorCopy definition BadDrawable (2) + +const BadBadDrawable = 2 + +type BadDrawableError GenericError + +func BadDrawableErrorNew(buf []byte) xgb.Error { + v := BadDrawableError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadDrawable" + return v +} + +func (err BadDrawableError) ImplementsError() {} + +func (err BadDrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadDrawableError) BadId() uint32 { + return 0 +} + +func (err BadDrawableError) 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 "BadBadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew +} + +// ErrorCopy definition BadPixmap (3) + +const BadBadPixmap = 3 + +type BadPixmapError GenericError + +func BadPixmapErrorNew(buf []byte) xgb.Error { + v := BadPixmapError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadPixmap" + return v +} + +func (err BadPixmapError) ImplementsError() {} + +func (err BadPixmapError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPixmapError) BadId() uint32 { + return 0 +} + +func (err BadPixmapError) 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 "BadBadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew +} + +// ErrorCopy definition BadContextTag (4) + +const BadBadContextTag = 4 + +type BadContextTagError GenericError + +func BadContextTagErrorNew(buf []byte) xgb.Error { + v := BadContextTagError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContextTag" + return v +} + +func (err BadContextTagError) ImplementsError() {} + +func (err BadContextTagError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextTagError) BadId() uint32 { + return 0 +} + +func (err BadContextTagError) 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 "BadBadContextTag {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew +} + +// ErrorCopy definition BadCurrentWindow (5) + +const BadBadCurrentWindow = 5 + +type BadCurrentWindowError GenericError + +func BadCurrentWindowErrorNew(buf []byte) xgb.Error { + v := BadCurrentWindowError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadCurrentWindow" + return v +} + +func (err BadCurrentWindowError) ImplementsError() {} + +func (err BadCurrentWindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadCurrentWindowError) BadId() uint32 { + return 0 +} + +func (err BadCurrentWindowError) 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 "BadBadCurrentWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][5] = BadCurrentWindowErrorNew +} + +// ErrorCopy definition BadRenderRequest (6) + +const BadBadRenderRequest = 6 + +type BadRenderRequestError GenericError + +func BadRenderRequestErrorNew(buf []byte) xgb.Error { + v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadRenderRequest" + return v +} + +func (err BadRenderRequestError) ImplementsError() {} + +func (err BadRenderRequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadRenderRequestError) BadId() uint32 { + return 0 +} + +func (err BadRenderRequestError) 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 "BadBadRenderRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew +} + +// ErrorCopy definition BadLargeRequest (7) + +const BadBadLargeRequest = 7 + +type BadLargeRequestError GenericError + +func BadLargeRequestErrorNew(buf []byte) xgb.Error { + v := BadLargeRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadLargeRequest" + return v +} + +func (err BadLargeRequestError) ImplementsError() {} + +func (err BadLargeRequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadLargeRequestError) BadId() uint32 { + return 0 +} + +func (err BadLargeRequestError) 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 "BadBadLargeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew +} + +// ErrorCopy definition UnsupportedPrivateRequest (8) + +const BadUnsupportedPrivateRequest = 8 + +type UnsupportedPrivateRequestError GenericError + +func UnsupportedPrivateRequestErrorNew(buf []byte) xgb.Error { + v := UnsupportedPrivateRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "UnsupportedPrivateRequest" + return v +} + +func (err UnsupportedPrivateRequestError) ImplementsError() {} + +func (err UnsupportedPrivateRequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err UnsupportedPrivateRequestError) BadId() uint32 { + return 0 +} + +func (err UnsupportedPrivateRequestError) 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 "BadUnsupportedPrivateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew +} + +// ErrorCopy definition BadFBConfig (9) + +const BadBadFBConfig = 9 + +type BadFBConfigError GenericError + +func BadFBConfigErrorNew(buf []byte) xgb.Error { + v := BadFBConfigError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadFBConfig" + return v +} + +func (err BadFBConfigError) ImplementsError() {} + +func (err BadFBConfigError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadFBConfigError) BadId() uint32 { + return 0 +} + +func (err BadFBConfigError) 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 "BadBadFBConfig {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew +} + +// ErrorCopy definition BadPbuffer (10) + +const BadBadPbuffer = 10 + +type BadPbufferError GenericError + +func BadPbufferErrorNew(buf []byte) xgb.Error { + v := BadPbufferError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadPbuffer" + return v +} + +func (err BadPbufferError) ImplementsError() {} + +func (err BadPbufferError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPbufferError) BadId() uint32 { + return 0 +} + +func (err BadPbufferError) 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 "BadBadPbuffer {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew +} + +// ErrorCopy definition BadCurrentDrawable (11) + +const BadBadCurrentDrawable = 11 + +type BadCurrentDrawableError GenericError + +func BadCurrentDrawableErrorNew(buf []byte) xgb.Error { + v := BadCurrentDrawableError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadCurrentDrawable" + return v +} + +func (err BadCurrentDrawableError) ImplementsError() {} + +func (err BadCurrentDrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadCurrentDrawableError) BadId() uint32 { + return 0 +} + +func (err BadCurrentDrawableError) 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 "BadBadCurrentDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew +} + +// ErrorCopy definition BadWindow (12) + +const BadBadWindow = 12 + +type BadWindowError GenericError + +func BadWindowErrorNew(buf []byte) xgb.Error { + v := BadWindowError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadWindow" + return v +} + +func (err BadWindowError) ImplementsError() {} + +func (err BadWindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadWindowError) BadId() uint32 { + return 0 +} + +func (err BadWindowError) 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 "BadBadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][12] = BadWindowErrorNew +} + +// ErrorCopy definition GLXBadProfileARB (13) + +const BadGLXBadProfileARB = 13 + +type GLXBadProfileARBError GenericError + +func GLXBadProfileARBErrorNew(buf []byte) xgb.Error { + v := GLXBadProfileARBError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "GLXBadProfileARB" + return v +} + +func (err GLXBadProfileARBError) ImplementsError() {} + +func (err GLXBadProfileARBError) SequenceId() uint16 { + return err.Sequence +} + +func (err GLXBadProfileARBError) BadId() uint32 { + return 0 +} + +func (err GLXBadProfileARBError) 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 "BadGLXBadProfileARB {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][13] = GLXBadProfileARBErrorNew +} + +// Request Render +// size: xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) +type RenderCookie struct { + *xgb.Cookie +} + +// Write request to wire for Render +func Render(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} +} + +func RenderChecked(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} +} + +func (cook RenderCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Render +func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request RenderLarge +// size: xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) +type RenderLargeCookie struct { + *xgb.Cookie +} + +// Write request to wire for RenderLarge +func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} + +func RenderLargeChecked(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} + +func (cook RenderLargeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RenderLarge +func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(ContextTag)) + b += 4 + + xgb.Put16(buf[b:], RequestNum) + b += 2 + + xgb.Put16(buf[b:], RequestTotal) + b += 2 + + xgb.Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:DataLen]) + b += xgb.Pad(int(DataLen)) + + return buf +} + +// Request CreateContext +// size: 24 +type CreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContext +func CreateContext(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextChecked(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) + return CreateContextCookie{cookie} +} + +func (cook CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request DestroyContext +// size: 8 +type DestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyContext +func DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{cookie} +} + +func DestroyContextChecked(c *xgb.Conn, Context Context) DestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{cookie} +} + +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +func destroyContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(Context)) + b += 4 + + return buf +} + +// Request MakeCurrent +// size: 16 +type MakeCurrentCookie struct { + *xgb.Cookie +} + +func MakeCurrent(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} +} + +func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} +} + +// Request reply for MakeCurrent +// size: 32 +type MakeCurrentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextTag ContextTag + // padding: 20 bytes +} + +// Waits and reads reply data from request MakeCurrent +func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return makeCurrentReply(buf), nil +} + +// Read reply into structure from buffer for MakeCurrent +func makeCurrentReply(buf []byte) *MakeCurrentReply { + v := new(MakeCurrentReply) + 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.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for MakeCurrent +func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(OldContextTag)) + b += 4 + + return buf +} + +// Request IsDirect +// size: 8 +type IsDirectCookie struct { + *xgb.Cookie +} + +func IsDirect(c *xgb.Conn, Context Context) IsDirectCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} +} + +func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} +} + +// Request reply for IsDirect +// size: 32 +type IsDirectReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IsDirect bool + // padding: 23 bytes +} + +// Waits and reads reply data from request IsDirect +func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isDirectReply(buf), nil +} + +// Read reply into structure from buffer for IsDirect +func isDirectReply(buf []byte) *IsDirectReply { + v := new(IsDirectReply) + 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.IsDirect = true + } else { + v.IsDirect = false + } + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for IsDirect +func isDirectRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(Context)) + b += 4 + + return buf +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), 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, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// Request WaitGL +// size: 8 +type WaitGLCookie struct { + *xgb.Cookie +} + +// Write request to wire for WaitGL +func WaitGL(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(waitGLRequest(c, ContextTag), cookie) + return WaitGLCookie{cookie} +} + +func WaitGLChecked(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(waitGLRequest(c, ContextTag), cookie) + return WaitGLCookie{cookie} +} + +func (cook WaitGLCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for WaitGL +func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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(ContextTag)) + b += 4 + + return buf +} + +// Request WaitX +// size: 8 +type WaitXCookie struct { + *xgb.Cookie +} + +// Write request to wire for WaitX +func WaitX(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} + +func WaitXChecked(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} + +func (cook WaitXCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for WaitX +func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request CopyContext +// size: 20 +type CopyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyContext +func CopyContext(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) + return CopyContextCookie{cookie} +} + +func CopyContextChecked(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) + return CopyContextCookie{cookie} +} + +func (cook CopyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyContext +func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dest)) + b += 4 + + xgb.Put32(buf[b:], Mask) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcContextTag)) + b += 4 + + return buf +} + +// Request SwapBuffers +// size: 12 +type SwapBuffersCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwapBuffers +func SwapBuffers(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} +} + +func SwapBuffersChecked(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} +} + +func (cook SwapBuffersCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwapBuffers +func swapBuffersRequest(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request UseXFont +// size: 24 +type UseXFontCookie struct { + *xgb.Cookie +} + +// Write request to wire for UseXFont +func UseXFont(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) + return UseXFontCookie{cookie} +} + +func UseXFontChecked(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) + return UseXFontCookie{cookie} +} + +func (cook UseXFontCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UseXFont +func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + xgb.Put32(buf[b:], First) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + xgb.Put32(buf[b:], ListBase) + b += 4 + + return buf +} + +// Request CreateGLXPixmap +// size: 20 +type CreateGLXPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGLXPixmap +func CreateGLXPixmap(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) + return CreateGLXPixmapCookie{cookie} +} + +func CreateGLXPixmapChecked(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) + return CreateGLXPixmapCookie{cookie} +} + +func (cook CreateGLXPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGLXPixmap +func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf +} + +// Request GetVisualConfigs +// size: 8 +type GetVisualConfigsCookie struct { + *xgb.Cookie +} + +func GetVisualConfigs(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} +} + +func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} +} + +// Request reply for GetVisualConfigs +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetVisualConfigsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumVisuals uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetVisualConfigs +func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVisualConfigsReply(buf), nil +} + +// Read reply into structure from buffer for GetVisualConfigs +func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { + v := new(GetVisualConfigsReply) + 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.NumVisuals = xgb.Get32(buf[b:]) + b += 4 + + v.NumProperties = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.PropertyList = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PropertyList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetVisualConfigs +func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request DestroyGLXPixmap +// size: 8 +type DestroyGLXPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyGLXPixmap +func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{cookie} +} + +func DestroyGLXPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{cookie} +} + +func (cook DestroyGLXPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyGLXPixmap +func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf +} + +// Request VendorPrivate +// size: xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +type VendorPrivateCookie struct { + *xgb.Cookie +} + +// Write request to wire for VendorPrivate +func VendorPrivate(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} +} + +func VendorPrivateChecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} +} + +func (cook VendorPrivateCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for VendorPrivate +func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], VendorCode) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request VendorPrivateWithReply +// size: xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +type VendorPrivateWithReplyCookie struct { + *xgb.Cookie +} + +func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} +} + +func VendorPrivateWithReplyUnchecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} +} + +// Request reply for VendorPrivateWithReply +// size: (36 + xgb.Pad(((int(Length) * 4) * 1))) +type VendorPrivateWithReplyReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Retval uint32 + Data1 []byte // size: 24 + Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request VendorPrivateWithReply +func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return vendorPrivateWithReplyReply(buf), nil +} + +// Read reply into structure from buffer for VendorPrivateWithReply +func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { + v := new(VendorPrivateWithReplyReply) + 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.Retval = xgb.Get32(buf[b:]) + b += 4 + + v.Data1 = make([]byte, 24) + copy(v.Data1[:24], buf[b:]) + b += xgb.Pad(int(24)) + + v.Data2 = make([]byte, (int(v.Length) * 4)) + copy(v.Data2[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for VendorPrivateWithReply +func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], VendorCode) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request QueryExtensionsString +// size: 8 +type QueryExtensionsStringCookie struct { + *xgb.Cookie +} + +func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} +} + +func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} +} + +// Request reply for QueryExtensionsString +// size: 32 +type QueryExtensionsStringReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryExtensionsString +func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionsStringReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtensionsString +func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { + v := new(QueryExtensionsStringReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryExtensionsString +func queryExtensionsStringRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request QueryServerString +// size: 12 +type QueryServerStringCookie struct { + *xgb.Cookie +} + +func QueryServerString(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} +} + +func QueryServerStringUnchecked(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} +} + +// Request reply for QueryServerString +// size: (32 + xgb.Pad((int(StrLen) * 1))) +type QueryServerStringReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + StrLen uint32 + // padding: 16 bytes + String string // size: xgb.Pad((int(StrLen) * 1)) +} + +// Waits and reads reply data from request QueryServerString +func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryServerStringReply(buf), nil +} + +// Read reply into structure from buffer for QueryServerString +func queryServerStringReply(buf []byte) *QueryServerStringReply { + v := new(QueryServerStringReply) + 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 += 4 // padding + + v.StrLen = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + { + byteString := make([]byte, v.StrLen) + copy(byteString[:v.StrLen], buf[b:]) + v.String = string(byteString) + b += xgb.Pad(int(v.StrLen)) + } + + return v +} + +// Write request to wire for QueryServerString +func queryServerStringRequest(c *xgb.Conn, Screen uint32, Name uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Name) + b += 4 + + return buf +} + +// Request ClientInfo +// size: xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) +type ClientInfoCookie struct { + *xgb.Cookie +} + +// Write request to wire for ClientInfo +func ClientInfo(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) + return ClientInfoCookie{cookie} +} + +func ClientInfoChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) + return ClientInfoCookie{cookie} +} + +func (cook ClientInfoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ClientInfo +func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], StrLen) + b += 4 + + copy(buf[b:], String[:StrLen]) + b += xgb.Pad(int(StrLen)) + + return buf +} + +// Request GetFBConfigs +// size: 8 +type GetFBConfigsCookie struct { + *xgb.Cookie +} + +func GetFBConfigs(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{cookie} +} + +func GetFBConfigsUnchecked(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{cookie} +} + +// Request reply for GetFBConfigs +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetFBConfigsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFbConfigs uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetFBConfigs +func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFBConfigsReply(buf), nil +} + +// Read reply into structure from buffer for GetFBConfigs +func getFBConfigsReply(buf []byte) *GetFBConfigsReply { + v := new(GetFBConfigsReply) + 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.NumFbConfigs = xgb.Get32(buf[b:]) + b += 4 + + v.NumProperties = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.PropertyList = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PropertyList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetFBConfigs +func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request CreatePixmap +// size: xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePixmap +func CreatePixmap(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} +} + +func CreatePixmapChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} +} + +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DestroyPixmap +// size: 8 +type DestroyPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyPixmap +func DestroyPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) + return DestroyPixmapCookie{cookie} +} + +func DestroyPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) + return DestroyPixmapCookie{cookie} +} + +func (cook DestroyPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyPixmap +func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf +} + +// Request CreateNewContext +// size: 28 +type CreateNewContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateNewContext +func CreateNewContext(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} +} + +func CreateNewContextChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} +} + +func (cook CreateNewContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateNewContext +func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], RenderType) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request QueryContext +// size: 8 +type QueryContextCookie struct { + *xgb.Cookie +} + +func QueryContext(c *xgb.Conn, Context Context) QueryContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryContextRequest(c, Context), cookie) + return QueryContextCookie{cookie} +} + +func QueryContextUnchecked(c *xgb.Conn, Context Context) QueryContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryContextRequest(c, Context), cookie) + return QueryContextCookie{cookie} +} + +// Request reply for QueryContext +// size: (32 + xgb.Pad(((int(NumAttribs) * 2) * 4))) +type QueryContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) +} + +// Waits and reads reply data from request QueryContext +func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryContextReply(buf), nil +} + +// Read reply into structure from buffer for QueryContext +func queryContextReply(buf []byte) *QueryContextReply { + v := new(QueryContextReply) + 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.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryContext +func queryContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request MakeContextCurrent +// size: 20 +type MakeContextCurrentCookie struct { + *xgb.Cookie +} + +func MakeContextCurrent(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} +} + +func MakeContextCurrentUnchecked(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} +} + +// Request reply for MakeContextCurrent +// size: 32 +type MakeContextCurrentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextTag ContextTag + // padding: 20 bytes +} + +// Waits and reads reply data from request MakeContextCurrent +func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return makeContextCurrentReply(buf), nil +} + +// Read reply into structure from buffer for MakeContextCurrent +func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { + v := new(MakeContextCurrentReply) + 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.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for MakeContextCurrent +func makeContextCurrentRequest(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(OldContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(ReadDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request CreatePbuffer +// size: xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreatePbufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePbuffer +func CreatePbuffer(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{cookie} +} + +func CreatePbufferChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{cookie} +} + +func (cook CreatePbufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePbuffer +func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pbuffer)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DestroyPbuffer +// size: 8 +type DestroyPbufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyPbuffer +func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{cookie} +} + +func DestroyPbufferChecked(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{cookie} +} + +func (cook DestroyPbufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyPbuffer +func destroyPbufferRequest(c *xgb.Conn, Pbuffer Pbuffer) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pbuffer)) + b += 4 + + return buf +} + +// Request GetDrawableAttributes +// size: 8 +type GetDrawableAttributesCookie struct { + *xgb.Cookie +} + +func GetDrawableAttributes(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{cookie} +} + +func GetDrawableAttributesUnchecked(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{cookie} +} + +// Request reply for GetDrawableAttributes +// size: (32 + xgb.Pad(((int(NumAttribs) * 2) * 4))) +type GetDrawableAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) +} + +// Waits and reads reply data from request GetDrawableAttributes +func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableAttributesReply(buf), nil +} + +// Read reply into structure from buffer for GetDrawableAttributes +func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { + v := new(GetDrawableAttributesReply) + 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.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDrawableAttributes +func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request ChangeDrawableAttributes +// size: xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type ChangeDrawableAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeDrawableAttributes +func ChangeDrawableAttributes(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{cookie} +} + +func ChangeDrawableAttributesChecked(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{cookie} +} + +func (cook ChangeDrawableAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDrawableAttributes +func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CreateWindow +// size: xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreateWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateWindow +func CreateWindow(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{cookie} +} + +func CreateWindowChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{cookie} +} + +func (cook CreateWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateWindow +func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 31 // 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 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxWindow)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DeleteWindow +// size: 8 +type DeleteWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteWindow +func DeleteWindow(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) + return DeleteWindowCookie{cookie} +} + +func DeleteWindowChecked(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) + return DeleteWindowCookie{cookie} +} + +func (cook DeleteWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteWindow +func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 32 // 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(Glxwindow)) + b += 4 + + return buf +} + +// Request SetClientInfoARB +// size: xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +type SetClientInfoARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClientInfoARB +func SetClientInfoARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} +} + +func SetClientInfoARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} +} + +func (cook SetClientInfoARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientInfoARB +func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 33 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], NumVersions) + b += 4 + + xgb.Put32(buf[b:], GlStrLen) + b += 4 + + xgb.Put32(buf[b:], GlxStrLen) + b += 4 + + for i := 0; i < int((int(NumVersions) * 2)); i++ { + xgb.Put32(buf[b:], GlVersions[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], GlExtensionString[:GlStrLen]) + b += xgb.Pad(int(GlStrLen)) + + copy(buf[b:], GlxExtensionString[:GlxStrLen]) + b += xgb.Pad(int(GlxStrLen)) + + return buf +} + +// Request CreateContextAttribsARB +// size: xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreateContextAttribsARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContextAttribsARB +func CreateContextAttribsARB(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{cookie} +} + +func CreateContextAttribsARBChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{cookie} +} + +func (cook CreateContextAttribsARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContextAttribsARB +func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 34 // 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(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request SetClientInfo2ARB +// size: xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +type SetClientInfo2ARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClientInfo2ARB +func SetClientInfo2ARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{cookie} +} + +func SetClientInfo2ARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{cookie} +} + +func (cook SetClientInfo2ARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientInfo2ARB +func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 35 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], NumVersions) + b += 4 + + xgb.Put32(buf[b:], GlStrLen) + b += 4 + + xgb.Put32(buf[b:], GlxStrLen) + b += 4 + + for i := 0; i < int((int(NumVersions) * 3)); i++ { + xgb.Put32(buf[b:], GlVersions[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], GlExtensionString[:GlStrLen]) + b += xgb.Pad(int(GlStrLen)) + + copy(buf[b:], GlxExtensionString[:GlxStrLen]) + b += xgb.Pad(int(GlxStrLen)) + + return buf +} + +// Request NewList +// size: 16 +type NewListCookie struct { + *xgb.Cookie +} + +// Write request to wire for NewList +func NewList(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} +} + +func NewListChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} +} + +func (cook NewListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for NewList +func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 101 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + xgb.Put32(buf[b:], Mode) + b += 4 + + return buf +} + +// Request EndList +// size: 8 +type EndListCookie struct { + *xgb.Cookie +} + +// Write request to wire for EndList +func EndList(c *xgb.Conn, ContextTag ContextTag) EndListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(endListRequest(c, ContextTag), cookie) + return EndListCookie{cookie} +} + +func EndListChecked(c *xgb.Conn, ContextTag ContextTag) EndListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(endListRequest(c, ContextTag), cookie) + return EndListCookie{cookie} +} + +func (cook EndListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for EndList +func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 102 // 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(ContextTag)) + b += 4 + + return buf +} + +// Request DeleteLists +// size: 16 +type DeleteListsCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteLists +func DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} +} + +func DeleteListsChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} +} + +func (cook DeleteListsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteLists +func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 103 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + xgb.Put32(buf[b:], uint32(Range)) + b += 4 + + return buf +} + +// Request GenLists +// size: 12 +type GenListsCookie struct { + *xgb.Cookie +} + +func GenLists(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{cookie} +} + +func GenListsUnchecked(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{cookie} +} + +// Request reply for GenLists +// size: 12 +type GenListsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal uint32 +} + +// Waits and reads reply data from request GenLists +func (cook GenListsCookie) Reply() (*GenListsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genListsReply(buf), nil +} + +// Read reply into structure from buffer for GenLists +func genListsReply(buf []byte) *GenListsReply { + v := new(GenListsReply) + 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.RetVal = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GenLists +func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 104 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Range)) + b += 4 + + return buf +} + +// Request FeedbackBuffer +// size: 16 +type FeedbackBufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for FeedbackBuffer +func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{cookie} +} + +func FeedbackBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{cookie} +} + +func (cook FeedbackBufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FeedbackBuffer +func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 105 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Size)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + return buf +} + +// Request SelectBuffer +// size: 12 +type SelectBufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectBuffer +func SelectBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} +} + +func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} +} + +func (cook SelectBufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectBuffer +func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 106 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Size)) + b += 4 + + return buf +} + +// Request RenderMode +// size: 12 +type RenderModeCookie struct { + *xgb.Cookie +} + +func RenderMode(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} +} + +func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} +} + +// Request reply for RenderMode +// size: (32 + xgb.Pad((int(N) * 4))) +type RenderModeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal uint32 + N uint32 + NewMode uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request RenderMode +func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return renderModeReply(buf), nil +} + +// Read reply into structure from buffer for RenderMode +func renderModeReply(buf []byte) *RenderModeReply { + v := new(RenderModeReply) + 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.RetVal = xgb.Get32(buf[b:]) + b += 4 + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.NewMode = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for RenderMode +func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 107 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Mode) + b += 4 + + return buf +} + +// Request Finish +// size: 8 +type FinishCookie struct { + *xgb.Cookie +} + +func Finish(c *xgb.Conn, ContextTag ContextTag) FinishCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} +} + +func FinishUnchecked(c *xgb.Conn, ContextTag ContextTag) FinishCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} +} + +// Request reply for Finish +// size: 8 +type FinishReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes +} + +// Waits and reads reply data from request Finish +func (cook FinishCookie) Reply() (*FinishReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return finishReply(buf), nil +} + +// Read reply into structure from buffer for Finish +func finishReply(buf []byte) *FinishReply { + v := new(FinishReply) + 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 + + return v +} + +// Write request to wire for Finish +func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 108 // 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(ContextTag)) + b += 4 + + return buf +} + +// Request PixelStoref +// size: 16 +type PixelStorefCookie struct { + *xgb.Cookie +} + +// Write request to wire for PixelStoref +func PixelStoref(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} +} + +func PixelStorefChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} +} + +func (cook PixelStorefCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PixelStoref +func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 109 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + xgb.Put32(buf[b:], uint32(Datum)) + b += 4 + + return buf +} + +// Request PixelStorei +// size: 16 +type PixelStoreiCookie struct { + *xgb.Cookie +} + +// Write request to wire for PixelStorei +func PixelStorei(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} +} + +func PixelStoreiChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} +} + +func (cook PixelStoreiCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PixelStorei +func pixelStoreiRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 110 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + xgb.Put32(buf[b:], uint32(Datum)) + b += 4 + + return buf +} + +// Request ReadPixels +// size: 36 +type ReadPixelsCookie struct { + *xgb.Cookie +} + +func ReadPixels(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) + return ReadPixelsCookie{cookie} +} + +func ReadPixelsUnchecked(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) + return ReadPixelsCookie{cookie} +} + +// Request reply for ReadPixels +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type ReadPixelsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request ReadPixels +func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return readPixelsReply(buf), nil +} + +// Read reply into structure from buffer for ReadPixels +func readPixelsReply(buf []byte) *ReadPixelsReply { + v := new(ReadPixelsReply) + 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.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for ReadPixels +func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 111 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(X)) + b += 4 + + xgb.Put32(buf[b:], uint32(Y)) + b += 4 + + xgb.Put32(buf[b:], uint32(Width)) + b += 4 + + xgb.Put32(buf[b:], uint32(Height)) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if LsbFirst { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetBooleanv +// size: 12 +type GetBooleanvCookie struct { + *xgb.Cookie +} + +func GetBooleanv(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} +} + +func GetBooleanvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} +} + +// Request reply for GetBooleanv +// size: (32 + xgb.Pad((int(N) * 1))) +type GetBooleanvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum bool + // padding: 15 bytes + Data []bool // size: xgb.Pad((int(N) * 1)) +} + +// Waits and reads reply data from request GetBooleanv +func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBooleanvReply(buf), nil +} + +// Read reply into structure from buffer for GetBooleanv +func getBooleanvReply(buf []byte) *GetBooleanvReply { + v := new(GetBooleanvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.Datum = true + } else { + v.Datum = false + } + b += 1 + + b += 15 // padding + + v.Data = make([]bool, v.N) + for i := 0; i < int(v.N); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetBooleanv +func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 112 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pname)) + b += 4 + + return buf +} + +// Request GetClipPlane +// size: 12 +type GetClipPlaneCookie struct { + *xgb.Cookie +} + +func GetClipPlane(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} +} + +func GetClipPlaneUnchecked(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} +} + +// Request reply for GetClipPlane +// size: (32 + xgb.Pad(((int(Length) / 2) * 8))) +type GetClipPlaneReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []Float64 // size: xgb.Pad(((int(Length) / 2) * 8)) +} + +// Waits and reads reply data from request GetClipPlane +func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClipPlaneReply(buf), nil +} + +// Read reply into structure from buffer for GetClipPlane +func getClipPlaneReply(buf []byte) *GetClipPlaneReply { + v := new(GetClipPlaneReply) + 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.Data = make([]Float64, (int(v.Length) / 2)) + for i := 0; i < int((int(v.Length) / 2)); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetClipPlane +func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 113 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Plane)) + b += 4 + + return buf +} + +// Request GetDoublev +// size: 12 +type GetDoublevCookie struct { + *xgb.Cookie +} + +func GetDoublev(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} +} + +func GetDoublevUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} +} + +// Request reply for GetDoublev +// size: (32 + xgb.Pad((int(N) * 8))) +type GetDoublevReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) +} + +// Waits and reads reply data from request GetDoublev +func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDoublevReply(buf), nil +} + +// Read reply into structure from buffer for GetDoublev +func getDoublevReply(buf []byte) *GetDoublevReply { + v := new(GetDoublevReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDoublev +func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 114 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetError +// size: 8 +type GetErrorCookie struct { + *xgb.Cookie +} + +func GetError(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{cookie} +} + +func GetErrorUnchecked(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{cookie} +} + +// Request reply for GetError +// size: 12 +type GetErrorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Error int32 +} + +// Waits and reads reply data from request GetError +func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getErrorReply(buf), nil +} + +// Read reply into structure from buffer for GetError +func getErrorReply(buf []byte) *GetErrorReply { + v := new(GetErrorReply) + 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.Error = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetError +func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 115 // 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(ContextTag)) + b += 4 + + return buf +} + +// Request GetFloatv +// size: 12 +type GetFloatvCookie struct { + *xgb.Cookie +} + +func GetFloatv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} +} + +func GetFloatvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} +} + +// Request reply for GetFloatv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetFloatvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetFloatv +func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFloatvReply(buf), nil +} + +// Read reply into structure from buffer for GetFloatv +func getFloatvReply(buf []byte) *GetFloatvReply { + v := new(GetFloatvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetFloatv +func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 116 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetIntegerv +// size: 12 +type GetIntegervCookie struct { + *xgb.Cookie +} + +func GetIntegerv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) + return GetIntegervCookie{cookie} +} + +func GetIntegervUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) + return GetIntegervCookie{cookie} +} + +// Request reply for GetIntegerv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetIntegervReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetIntegerv +func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getIntegervReply(buf), nil +} + +// Read reply into structure from buffer for GetIntegerv +func getIntegervReply(buf []byte) *GetIntegervReply { + v := new(GetIntegervReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetIntegerv +func getIntegervRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 117 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetLightfv +// size: 16 +type GetLightfvCookie struct { + *xgb.Cookie +} + +func GetLightfv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) + return GetLightfvCookie{cookie} +} + +func GetLightfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) + return GetLightfvCookie{cookie} +} + +// Request reply for GetLightfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetLightfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetLightfv +func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getLightfvReply(buf), nil +} + +// Read reply into structure from buffer for GetLightfv +func getLightfvReply(buf []byte) *GetLightfvReply { + v := new(GetLightfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetLightfv +func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 118 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Light) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetLightiv +// size: 16 +type GetLightivCookie struct { + *xgb.Cookie +} + +func GetLightiv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) + return GetLightivCookie{cookie} +} + +func GetLightivUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) + return GetLightivCookie{cookie} +} + +// Request reply for GetLightiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetLightivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetLightiv +func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getLightivReply(buf), nil +} + +// Read reply into structure from buffer for GetLightiv +func getLightivReply(buf []byte) *GetLightivReply { + v := new(GetLightivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetLightiv +func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 119 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Light) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMapdv +// size: 16 +type GetMapdvCookie struct { + *xgb.Cookie +} + +func GetMapdv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) + return GetMapdvCookie{cookie} +} + +func GetMapdvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) + return GetMapdvCookie{cookie} +} + +// Request reply for GetMapdv +// size: (32 + xgb.Pad((int(N) * 8))) +type GetMapdvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) +} + +// Waits and reads reply data from request GetMapdv +func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMapdvReply(buf), nil +} + +// Read reply into structure from buffer for GetMapdv +func getMapdvReply(buf []byte) *GetMapdvReply { + v := new(GetMapdvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMapdv +func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 120 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) + b += 4 + + return buf +} + +// Request GetMapfv +// size: 16 +type GetMapfvCookie struct { + *xgb.Cookie +} + +func GetMapfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) + return GetMapfvCookie{cookie} +} + +func GetMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) + return GetMapfvCookie{cookie} +} + +// Request reply for GetMapfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMapfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMapfv +func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMapfvReply(buf), nil +} + +// Read reply into structure from buffer for GetMapfv +func getMapfvReply(buf []byte) *GetMapfvReply { + v := new(GetMapfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMapfv +func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 121 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) + b += 4 + + return buf +} + +// Request GetMapiv +// size: 16 +type GetMapivCookie struct { + *xgb.Cookie +} + +func GetMapiv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) + return GetMapivCookie{cookie} +} + +func GetMapivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) + return GetMapivCookie{cookie} +} + +// Request reply for GetMapiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMapivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMapiv +func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMapivReply(buf), nil +} + +// Read reply into structure from buffer for GetMapiv +func getMapivReply(buf []byte) *GetMapivReply { + v := new(GetMapivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMapiv +func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 122 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) + b += 4 + + return buf +} + +// Request GetMaterialfv +// size: 16 +type GetMaterialfvCookie struct { + *xgb.Cookie +} + +func GetMaterialfv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialfvCookie{cookie} +} + +func GetMaterialfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialfvCookie{cookie} +} + +// Request reply for GetMaterialfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMaterialfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMaterialfv +func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMaterialfvReply(buf), nil +} + +// Read reply into structure from buffer for GetMaterialfv +func getMaterialfvReply(buf []byte) *GetMaterialfvReply { + v := new(GetMaterialfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMaterialfv +func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 123 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Face) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMaterialiv +// size: 16 +type GetMaterialivCookie struct { + *xgb.Cookie +} + +func GetMaterialiv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialivCookie{cookie} +} + +func GetMaterialivUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialivCookie{cookie} +} + +// Request reply for GetMaterialiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMaterialivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMaterialiv +func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMaterialivReply(buf), nil +} + +// Read reply into structure from buffer for GetMaterialiv +func getMaterialivReply(buf []byte) *GetMaterialivReply { + v := new(GetMaterialivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMaterialiv +func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 124 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Face) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetPixelMapfv +// size: 12 +type GetPixelMapfvCookie struct { + *xgb.Cookie +} + +func GetPixelMapfv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) + return GetPixelMapfvCookie{cookie} +} + +func GetPixelMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) + return GetPixelMapfvCookie{cookie} +} + +// Request reply for GetPixelMapfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetPixelMapfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetPixelMapfv +func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPixelMapfvReply(buf), nil +} + +// Read reply into structure from buffer for GetPixelMapfv +func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { + v := new(GetPixelMapfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetPixelMapfv +func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 125 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Map) + b += 4 + + return buf +} + +// Request GetPixelMapuiv +// size: 12 +type GetPixelMapuivCookie struct { + *xgb.Cookie +} + +func GetPixelMapuiv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) + return GetPixelMapuivCookie{cookie} +} + +func GetPixelMapuivUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) + return GetPixelMapuivCookie{cookie} +} + +// Request reply for GetPixelMapuiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetPixelMapuivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetPixelMapuiv +func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPixelMapuivReply(buf), nil +} + +// Read reply into structure from buffer for GetPixelMapuiv +func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { + v := new(GetPixelMapuivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetPixelMapuiv +func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 126 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Map) + b += 4 + + return buf +} + +// Request GetPixelMapusv +// size: 12 +type GetPixelMapusvCookie struct { + *xgb.Cookie +} + +func GetPixelMapusv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) + return GetPixelMapusvCookie{cookie} +} + +func GetPixelMapusvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) + return GetPixelMapusvCookie{cookie} +} + +// Request reply for GetPixelMapusv +// size: (34 + xgb.Pad((int(N) * 2))) +type GetPixelMapusvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint16 + // padding: 16 bytes + Data []uint16 // size: xgb.Pad((int(N) * 2)) +} + +// Waits and reads reply data from request GetPixelMapusv +func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPixelMapusvReply(buf), nil +} + +// Read reply into structure from buffer for GetPixelMapusv +func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { + v := new(GetPixelMapusvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get16(buf[b:]) + b += 2 + + b += 16 // padding + + v.Data = make([]uint16, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetPixelMapusv +func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 127 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Map) + b += 4 + + return buf +} + +// Request GetPolygonStipple +// size: 12 +type GetPolygonStippleCookie struct { + *xgb.Cookie +} + +func GetPolygonStipple(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) + return GetPolygonStippleCookie{cookie} +} + +func GetPolygonStippleUnchecked(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) + return GetPolygonStippleCookie{cookie} +} + +// Request reply for GetPolygonStipple +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetPolygonStippleReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetPolygonStipple +func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPolygonStippleReply(buf), nil +} + +// Read reply into structure from buffer for GetPolygonStipple +func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { + v := new(GetPolygonStippleReply) + 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.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetPolygonStipple +func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 128 // 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(ContextTag)) + b += 4 + + if LsbFirst { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetString +// size: 12 +type GetStringCookie struct { + *xgb.Cookie +} + +func GetString(c *xgb.Conn, ContextTag ContextTag, Name uint32) GetStringCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getStringRequest(c, ContextTag, Name), cookie) + return GetStringCookie{cookie} +} + +func GetStringUnchecked(c *xgb.Conn, ContextTag ContextTag, Name uint32) GetStringCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getStringRequest(c, ContextTag, Name), cookie) + return GetStringCookie{cookie} +} + +// Request reply for GetString +// size: (32 + xgb.Pad((int(N) * 1))) +type GetStringReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + // padding: 16 bytes + String string // size: xgb.Pad((int(N) * 1)) +} + +// Waits and reads reply data from request GetString +func (cook GetStringCookie) Reply() (*GetStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getStringReply(buf), nil +} + +// Read reply into structure from buffer for GetString +func getStringReply(buf []byte) *GetStringReply { + v := new(GetStringReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + { + byteString := make([]byte, v.N) + copy(byteString[:v.N], buf[b:]) + v.String = string(byteString) + b += xgb.Pad(int(v.N)) + } + + return v +} + +// Write request to wire for GetString +func getStringRequest(c *xgb.Conn, ContextTag ContextTag, Name uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 129 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Name) + b += 4 + + return buf +} + +// Request GetTexEnvfv +// size: 16 +type GetTexEnvfvCookie struct { + *xgb.Cookie +} + +func GetTexEnvfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexEnvfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvfvCookie{cookie} +} + +func GetTexEnvfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexEnvfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvfvCookie{cookie} +} + +// Request reply for GetTexEnvfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexEnvfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexEnvfv +func (cook GetTexEnvfvCookie) Reply() (*GetTexEnvfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexEnvfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexEnvfv +func getTexEnvfvReply(buf []byte) *GetTexEnvfvReply { + v := new(GetTexEnvfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexEnvfv +func getTexEnvfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 130 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexEnviv +// size: 16 +type GetTexEnvivCookie struct { + *xgb.Cookie +} + +func GetTexEnviv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexEnvivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvivCookie{cookie} +} + +func GetTexEnvivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexEnvivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvivCookie{cookie} +} + +// Request reply for GetTexEnviv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexEnvivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexEnviv +func (cook GetTexEnvivCookie) Reply() (*GetTexEnvivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexEnvivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexEnviv +func getTexEnvivReply(buf []byte) *GetTexEnvivReply { + v := new(GetTexEnvivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexEnviv +func getTexEnvivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 131 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexGendv +// size: 16 +type GetTexGendvCookie struct { + *xgb.Cookie +} + +func GetTexGendv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGendvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexGendvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGendvCookie{cookie} +} + +func GetTexGendvUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGendvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexGendvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGendvCookie{cookie} +} + +// Request reply for GetTexGendv +// size: (32 + xgb.Pad((int(N) * 8))) +type GetTexGendvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) +} + +// Waits and reads reply data from request GetTexGendv +func (cook GetTexGendvCookie) Reply() (*GetTexGendvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexGendvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexGendv +func getTexGendvReply(buf []byte) *GetTexGendvReply { + v := new(GetTexGendvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexGendv +func getTexGendvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 132 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Coord) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexGenfv +// size: 16 +type GetTexGenfvCookie struct { + *xgb.Cookie +} + +func GetTexGenfv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexGenfvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenfvCookie{cookie} +} + +func GetTexGenfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexGenfvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenfvCookie{cookie} +} + +// Request reply for GetTexGenfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexGenfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexGenfv +func (cook GetTexGenfvCookie) Reply() (*GetTexGenfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexGenfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexGenfv +func getTexGenfvReply(buf []byte) *GetTexGenfvReply { + v := new(GetTexGenfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexGenfv +func getTexGenfvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 133 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Coord) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexGeniv +// size: 16 +type GetTexGenivCookie struct { + *xgb.Cookie +} + +func GetTexGeniv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexGenivRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenivCookie{cookie} +} + +func GetTexGenivUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexGenivRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenivCookie{cookie} +} + +// Request reply for GetTexGeniv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexGenivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexGeniv +func (cook GetTexGenivCookie) Reply() (*GetTexGenivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexGenivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexGeniv +func getTexGenivReply(buf []byte) *GetTexGenivReply { + v := new(GetTexGenivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexGeniv +func getTexGenivRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 134 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Coord) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexImage +// size: 28 +type GetTexImageCookie struct { + *xgb.Cookie +} + +func GetTexImage(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) + return GetTexImageCookie{cookie} +} + +func GetTexImageUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) + return GetTexImageCookie{cookie} +} + +// Request reply for GetTexImage +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetTexImageReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + Height int32 + Depth int32 + // padding: 4 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetTexImage +func (cook GetTexImageCookie) Reply() (*GetTexImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexImageReply(buf), nil +} + +// Read reply into structure from buffer for GetTexImage +func getTexImageReply(buf []byte) *GetTexImageReply { + v := new(GetTexImageReply) + 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 += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 4 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetTexImage +func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 135 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetTexParameterfv +// size: 16 +type GetTexParameterfvCookie struct { + *xgb.Cookie +} + +func GetTexParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} +} + +func GetTexParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} +} + +// Request reply for GetTexParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexParameterfv +func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexParameterfv +func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { + v := new(GetTexParameterfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexParameterfv +func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 136 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexParameteriv +// size: 16 +type GetTexParameterivCookie struct { + *xgb.Cookie +} + +func GetTexParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{cookie} +} + +func GetTexParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{cookie} +} + +// Request reply for GetTexParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexParameteriv +func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexParameteriv +func getTexParameterivReply(buf []byte) *GetTexParameterivReply { + v := new(GetTexParameterivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexParameteriv +func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 137 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexLevelParameterfv +// size: 20 +type GetTexLevelParameterfvCookie struct { + *xgb.Cookie +} + +func GetTexLevelParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterfvCookie{cookie} +} + +func GetTexLevelParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterfvCookie{cookie} +} + +// Request reply for GetTexLevelParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexLevelParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexLevelParameterfv +func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexLevelParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexLevelParameterfv +func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { + v := new(GetTexLevelParameterfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexLevelParameterfv +func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 138 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexLevelParameteriv +// size: 20 +type GetTexLevelParameterivCookie struct { + *xgb.Cookie +} + +func GetTexLevelParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterivCookie{cookie} +} + +func GetTexLevelParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterivCookie{cookie} +} + +// Request reply for GetTexLevelParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexLevelParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexLevelParameteriv +func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexLevelParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexLevelParameteriv +func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { + v := new(GetTexLevelParameterivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexLevelParameteriv +func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 139 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request IsList +// size: 12 +type IsListCookie struct { + *xgb.Cookie +} + +func IsList(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} +} + +func IsListUnchecked(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} +} + +// Request reply for IsList +// size: 12 +type IsListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 +} + +// Waits and reads reply data from request IsList +func (cook IsListCookie) Reply() (*IsListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isListReply(buf), nil +} + +// Read reply into structure from buffer for IsList +func isListReply(buf []byte) *IsListReply { + v := new(IsListReply) + 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.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for IsList +func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 141 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + return buf +} + +// Request Flush +// size: 8 +type FlushCookie struct { + *xgb.Cookie +} + +// Write request to wire for Flush +func Flush(c *xgb.Conn, ContextTag ContextTag) FlushCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(flushRequest(c, ContextTag), cookie) + return FlushCookie{cookie} +} + +func FlushChecked(c *xgb.Conn, ContextTag ContextTag) FlushCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(flushRequest(c, ContextTag), cookie) + return FlushCookie{cookie} +} + +func (cook FlushCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Flush +func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 142 // 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(ContextTag)) + b += 4 + + return buf +} + +// Request AreTexturesResident +// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +type AreTexturesResidentCookie struct { + *xgb.Cookie +} + +func AreTexturesResident(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{cookie} +} + +func AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{cookie} +} + +// Request reply for AreTexturesResident +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type AreTexturesResidentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 + // padding: 20 bytes + Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request AreTexturesResident +func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return areTexturesResidentReply(buf), nil +} + +// Read reply into structure from buffer for AreTexturesResident +func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { + v := new(AreTexturesResidentReply) + 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.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + v.Data = make([]bool, (int(v.Length) * 4)) + for i := 0; i < int((int(v.Length) * 4)); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for AreTexturesResident +func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 143 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DeleteTextures +// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +type DeleteTexturesCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteTextures +func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} +} + +func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} +} + +func (cook DeleteTexturesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteTextures +func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 144 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GenTextures +// size: 12 +type GenTexturesCookie struct { + *xgb.Cookie +} + +func GenTextures(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} +} + +func GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} +} + +// Request reply for GenTextures +// size: (32 + xgb.Pad((int(Length) * 4))) +type GenTexturesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GenTextures +func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genTexturesReply(buf), nil +} + +// Read reply into structure from buffer for GenTextures +func genTexturesReply(buf []byte) *GenTexturesReply { + v := new(GenTexturesReply) + 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.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GenTextures +func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 145 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + return buf +} + +// Request IsTexture +// size: 12 +type IsTextureCookie struct { + *xgb.Cookie +} + +func IsTexture(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} +} + +func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} +} + +// Request reply for IsTexture +// size: 12 +type IsTextureReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 +} + +// Waits and reads reply data from request IsTexture +func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isTextureReply(buf), nil +} + +// Read reply into structure from buffer for IsTexture +func isTextureReply(buf []byte) *IsTextureReply { + v := new(IsTextureReply) + 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.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for IsTexture +func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 146 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Texture) + b += 4 + + return buf +} + +// Request GetColorTable +// size: 24 +type GetColorTableCookie struct { + *xgb.Cookie +} + +func GetColorTable(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{cookie} +} + +func GetColorTableUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{cookie} +} + +// Request reply for GetColorTable +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetColorTableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetColorTable +func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableReply(buf), nil +} + +// Read reply into structure from buffer for GetColorTable +func getColorTableReply(buf []byte) *GetColorTableReply { + v := new(GetColorTableReply) + 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 += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetColorTable +func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 147 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetColorTableParameterfv +// size: 16 +type GetColorTableParameterfvCookie struct { + *xgb.Cookie +} + +func GetColorTableParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} +} + +func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} +} + +// Request reply for GetColorTableParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetColorTableParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetColorTableParameterfv +func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetColorTableParameterfv +func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { + v := new(GetColorTableParameterfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetColorTableParameterfv +func getColorTableParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 148 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetColorTableParameteriv +// size: 16 +type GetColorTableParameterivCookie struct { + *xgb.Cookie +} + +func GetColorTableParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} +} + +func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} +} + +// Request reply for GetColorTableParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetColorTableParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetColorTableParameteriv +func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetColorTableParameteriv +func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { + v := new(GetColorTableParameterivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetColorTableParameteriv +func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 149 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetConvolutionFilter +// size: 24 +type GetConvolutionFilterCookie struct { + *xgb.Cookie +} + +func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} +} + +func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} +} + +// Request reply for GetConvolutionFilter +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetConvolutionFilterReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + Height int32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetConvolutionFilter +func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionFilterReply(buf), nil +} + +// Read reply into structure from buffer for GetConvolutionFilter +func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { + v := new(GetConvolutionFilterReply) + 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 += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetConvolutionFilter +func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 150 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetConvolutionParameterfv +// size: 16 +type GetConvolutionParameterfvCookie struct { + *xgb.Cookie +} + +func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} +} + +func GetConvolutionParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} +} + +// Request reply for GetConvolutionParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetConvolutionParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetConvolutionParameterfv +func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetConvolutionParameterfv +func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply { + v := new(GetConvolutionParameterfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetConvolutionParameterfv +func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 151 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetConvolutionParameteriv +// size: 16 +type GetConvolutionParameterivCookie struct { + *xgb.Cookie +} + +func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} +} + +func GetConvolutionParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} +} + +// Request reply for GetConvolutionParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetConvolutionParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetConvolutionParameteriv +func (cook GetConvolutionParameterivCookie) Reply() (*GetConvolutionParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetConvolutionParameteriv +func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { + v := new(GetConvolutionParameterivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetConvolutionParameteriv +func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 152 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetSeparableFilter +// size: 24 +type GetSeparableFilterCookie struct { + *xgb.Cookie +} + +func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +// Request reply for GetSeparableFilter +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetSeparableFilterReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + RowW int32 + ColH int32 + // padding: 8 bytes + RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetSeparableFilter +func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSeparableFilterReply(buf), nil +} + +// Read reply into structure from buffer for GetSeparableFilter +func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { + v := new(GetSeparableFilterReply) + 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 += 8 // padding + + v.RowW = int32(xgb.Get32(buf[b:])) + b += 4 + + v.ColH = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.RowsAndCols = make([]byte, (int(v.Length) * 4)) + copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetSeparableFilter +func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 153 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetHistogram +// size: 24 +type GetHistogramCookie struct { + *xgb.Cookie +} + +func GetHistogram(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} +} + +func GetHistogramUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} +} + +// Request reply for GetHistogram +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetHistogramReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetHistogram +func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramReply(buf), nil +} + +// Read reply into structure from buffer for GetHistogram +func getHistogramReply(buf []byte) *GetHistogramReply { + v := new(GetHistogramReply) + 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 += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetHistogram +func getHistogramRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 154 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetHistogramParameterfv +// size: 16 +type GetHistogramParameterfvCookie struct { + *xgb.Cookie +} + +func GetHistogramParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{cookie} +} + +func GetHistogramParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{cookie} +} + +// Request reply for GetHistogramParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetHistogramParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetHistogramParameterfv +func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetHistogramParameterfv +func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { + v := new(GetHistogramParameterfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetHistogramParameterfv +func getHistogramParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 155 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetHistogramParameteriv +// size: 16 +type GetHistogramParameterivCookie struct { + *xgb.Cookie +} + +func GetHistogramParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} +} + +func GetHistogramParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} +} + +// Request reply for GetHistogramParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetHistogramParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetHistogramParameteriv +func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetHistogramParameteriv +func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { + v := new(GetHistogramParameterivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetHistogramParameteriv +func getHistogramParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 156 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMinmax +// size: 24 +type GetMinmaxCookie struct { + *xgb.Cookie +} + +func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +// Request reply for GetMinmax +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetMinmaxReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetMinmax +func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxReply(buf), nil +} + +// Read reply into structure from buffer for GetMinmax +func getMinmaxReply(buf []byte) *GetMinmaxReply { + v := new(GetMinmaxReply) + 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.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetMinmax +func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 157 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetMinmaxParameterfv +// size: 16 +type GetMinmaxParameterfvCookie struct { + *xgb.Cookie +} + +func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +// Request reply for GetMinmaxParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMinmaxParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMinmaxParameterfv +func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetMinmaxParameterfv +func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { + v := new(GetMinmaxParameterfvReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameterfv +func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 158 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMinmaxParameteriv +// size: 16 +type GetMinmaxParameterivCookie struct { + *xgb.Cookie +} + +func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +// Request reply for GetMinmaxParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMinmaxParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMinmaxParameteriv +func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetMinmaxParameteriv +func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { + v := new(GetMinmaxParameterivReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameteriv +func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 159 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetCompressedTexImageARB +// size: 16 +type GetCompressedTexImageARBCookie struct { + *xgb.Cookie +} + +func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} +} + +func GetCompressedTexImageARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} +} + +// Request reply for GetCompressedTexImageARB +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetCompressedTexImageARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Size int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetCompressedTexImageARB +func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCompressedTexImageARBReply(buf), nil +} + +// Read reply into structure from buffer for GetCompressedTexImageARB +func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { + v := new(GetCompressedTexImageARBReply) + 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 += 8 // padding + + v.Size = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetCompressedTexImageARB +func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 160 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + return buf +} + +// Request DeleteQueriesARB +// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +type DeleteQueriesARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteQueriesARB +func DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} +} + +func DeleteQueriesARBChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} +} + +func (cook DeleteQueriesARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteQueriesARB +func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 161 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Ids[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GenQueriesARB +// size: 12 +type GenQueriesARBCookie struct { + *xgb.Cookie +} + +func GenQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} +} + +func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} +} + +// Request reply for GenQueriesARB +// size: (32 + xgb.Pad((int(Length) * 4))) +type GenQueriesARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GenQueriesARB +func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genQueriesARBReply(buf), nil +} + +// Read reply into structure from buffer for GenQueriesARB +func genQueriesARBReply(buf []byte) *GenQueriesARBReply { + v := new(GenQueriesARBReply) + 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.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GenQueriesARB +func genQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 162 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + return buf +} + +// Request IsQueryARB +// size: 12 +type IsQueryARBCookie struct { + *xgb.Cookie +} + +func IsQueryARB(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} +} + +func IsQueryARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} +} + +// Request reply for IsQueryARB +// size: 12 +type IsQueryARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 +} + +// Waits and reads reply data from request IsQueryARB +func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isQueryARBReply(buf), nil +} + +// Read reply into structure from buffer for IsQueryARB +func isQueryARBReply(buf []byte) *IsQueryARBReply { + v := new(IsQueryARBReply) + 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.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for IsQueryARB +func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 163 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + return buf +} + +// Request GetQueryivARB +// size: 16 +type GetQueryivARBCookie struct { + *xgb.Cookie +} + +func GetQueryivARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +// Request reply for GetQueryivARB +// size: (32 + xgb.Pad((int(N) * 4))) +type GetQueryivARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetQueryivARB +func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryivARBReply(buf), nil +} + +// Read reply into structure from buffer for GetQueryivARB +func getQueryivARBReply(buf []byte) *GetQueryivARBReply { + v := new(GetQueryivARBReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryivARB +func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 164 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetQueryObjectivARB +// size: 16 +type GetQueryObjectivARBCookie struct { + *xgb.Cookie +} + +func GetQueryObjectivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +// Request reply for GetQueryObjectivARB +// size: (32 + xgb.Pad((int(N) * 4))) +type GetQueryObjectivARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetQueryObjectivARB +func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectivARBReply(buf), nil +} + +// Read reply into structure from buffer for GetQueryObjectivARB +func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { + v := new(GetQueryObjectivARBReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectivARB +func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 165 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetQueryObjectuivARB +// size: 16 +type GetQueryObjectuivARBCookie struct { + *xgb.Cookie +} + +func GetQueryObjectuivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +// Request reply for GetQueryObjectuivARB +// size: (32 + xgb.Pad((int(N) * 4))) +type GetQueryObjectuivARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetQueryObjectuivARB +func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectuivARBReply(buf), nil +} + +// Read reply into structure from buffer for GetQueryObjectuivARB +func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { + v := new(GetQueryObjectuivARBReply) + 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 += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectuivARB +func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 166 // 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go new file mode 100644 index 0000000..4d78691 --- /dev/null +++ b/nexgb/randr/randr.go @@ -0,0 +1,3964 @@ +package randr + +/* + This file was generated by randr.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/render" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the RANDR extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 5, "RANDR").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named RANDR could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["RANDR"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["RANDR"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["RANDR"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["RANDR"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["RANDR"] = 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 ( + RotationRotate0 = 1 + RotationRotate90 = 2 + RotationRotate180 = 4 + RotationRotate270 = 8 + RotationReflectX = 16 + RotationReflectY = 32 +) + +const ( + SetConfigSuccess = 0 + SetConfigInvalidConfigTime = 1 + SetConfigInvalidTime = 2 + SetConfigFailed = 3 +) + +const ( + NotifyMaskScreenChange = 1 + NotifyMaskCrtcChange = 2 + NotifyMaskOutputChange = 4 + NotifyMaskOutputProperty = 8 +) + +const ( + ModeFlagHsyncPositive = 1 + ModeFlagHsyncNegative = 2 + ModeFlagVsyncPositive = 4 + ModeFlagVsyncNegative = 8 + ModeFlagInterlace = 16 + ModeFlagDoubleScan = 32 + ModeFlagCsync = 64 + ModeFlagCsyncPositive = 128 + ModeFlagCsyncNegative = 256 + ModeFlagHskewPresent = 512 + ModeFlagBcast = 1024 + ModeFlagPixelMultiplex = 2048 + ModeFlagDoubleClock = 4096 + ModeFlagHalveClock = 8192 +) + +const ( + ConnectionConnected = 0 + ConnectionDisconnected = 1 + ConnectionUnknown = 2 +) + +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 2 +) + +type Mode uint32 + +func NewModeId(c *xgb.Conn) (Mode, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Mode(id), nil +} + +type Crtc uint32 + +func NewCrtcId(c *xgb.Conn) (Crtc, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Crtc(id), nil +} + +type Output uint32 + +func NewOutputId(c *xgb.Conn) (Output, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Output(id), nil +} + +// 'ScreenSize' struct definition +// Size: 8 +type ScreenSize struct { + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 +} + +// Struct read ScreenSize +func ScreenSizeRead(buf []byte, v *ScreenSize) int { + b := 0 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 + + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read ScreenSize +func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenSize{} + b += ScreenSizeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ScreenSize +func (v ScreenSize) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Mwidth) + b += 2 + + xgb.Put16(buf[b:], v.Mheight) + b += 2 + + return buf +} + +// Write struct list ScreenSize +func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'RefreshRates' struct definition +// Size: (2 + xgb.Pad((int(NRates) * 2))) +type RefreshRates struct { + NRates uint16 + Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) +} + +// Struct read RefreshRates +func RefreshRatesRead(buf []byte, v *RefreshRates) int { + b := 0 + + v.NRates = xgb.Get16(buf[b:]) + b += 2 + + v.Rates = make([]uint16, v.NRates) + for i := 0; i < int(v.NRates); i++ { + v.Rates[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read RefreshRates +func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = RefreshRates{} + b += RefreshRatesRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write RefreshRates +func (v RefreshRates) Bytes() []byte { + buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) + b := 0 + + xgb.Put16(buf[b:], v.NRates) + b += 2 + + for i := 0; i < int(v.NRates); i++ { + xgb.Put16(buf[b:], v.Rates[i]) + b += 2 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list RefreshRates +func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size RefreshRates +func RefreshRatesListSize(list []RefreshRates) int { + size := 0 + for _, item := range list { + size += (2 + xgb.Pad((int(item.NRates) * 2))) + } + return size +} + +// 'ModeInfo' struct definition +// Size: 32 +type ModeInfo struct { + Id uint32 + Width uint16 + Height uint16 + DotClock uint32 + HsyncStart uint16 + HsyncEnd uint16 + Htotal uint16 + Hskew uint16 + VsyncStart uint16 + VsyncEnd uint16 + Vtotal uint16 + NameLen uint16 + ModeFlags uint32 +} + +// Struct read ModeInfo +func ModeInfoRead(buf []byte, v *ModeInfo) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.DotClock = xgb.Get32(buf[b:]) + b += 4 + + v.HsyncStart = xgb.Get16(buf[b:]) + b += 2 + + v.HsyncEnd = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get16(buf[b:]) + b += 2 + + v.VsyncStart = xgb.Get16(buf[b:]) + b += 2 + + v.VsyncEnd = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + v.ModeFlags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read ModeInfo +func ModeInfoReadList(buf []byte, dest []ModeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ModeInfo{} + b += ModeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ModeInfo +func (v ModeInfo) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put32(buf[b:], v.DotClock) + b += 4 + + xgb.Put16(buf[b:], v.HsyncStart) + b += 2 + + xgb.Put16(buf[b:], v.HsyncEnd) + b += 2 + + xgb.Put16(buf[b:], v.Htotal) + b += 2 + + xgb.Put16(buf[b:], v.Hskew) + b += 2 + + xgb.Put16(buf[b:], v.VsyncStart) + b += 2 + + xgb.Put16(buf[b:], v.VsyncEnd) + b += 2 + + xgb.Put16(buf[b:], v.Vtotal) + b += 2 + + xgb.Put16(buf[b:], v.NameLen) + b += 2 + + xgb.Put32(buf[b:], v.ModeFlags) + b += 4 + + return buf +} + +// Write struct list ModeInfo +func ModeInfoListBytes(buf []byte, list []ModeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'CrtcChange' struct definition +// Size: 28 +type CrtcChange struct { + Timestamp xproto.Timestamp + Window xproto.Window + Crtc Crtc + Mode Mode + Rotation uint16 + // padding: 2 bytes + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// Struct read CrtcChange +func CrtcChangeRead(buf []byte, v *CrtcChange) int { + b := 0 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read CrtcChange +func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = CrtcChange{} + b += CrtcChangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write CrtcChange +func (v CrtcChange) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Mode)) + b += 4 + + xgb.Put16(buf[b:], v.Rotation) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list CrtcChange +func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'OutputChange' struct definition +// Size: 28 +type OutputChange struct { + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Window xproto.Window + Output Output + Crtc Crtc + Mode Mode + Rotation uint16 + Connection byte + SubpixelOrder byte +} + +// Struct read OutputChange +func OutputChangeRead(buf []byte, v *OutputChange) int { + b := 0 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Output = Output(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Connection = buf[b] + b += 1 + + v.SubpixelOrder = buf[b] + b += 1 + + return b +} + +// Struct list read OutputChange +func OutputChangeReadList(buf []byte, dest []OutputChange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = OutputChange{} + b += OutputChangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write OutputChange +func (v OutputChange) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.ConfigTimestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Mode)) + b += 4 + + xgb.Put16(buf[b:], v.Rotation) + b += 2 + + buf[b] = v.Connection + b += 1 + + buf[b] = v.SubpixelOrder + b += 1 + + return buf +} + +// Write struct list OutputChange +func OutputChangeListBytes(buf []byte, list []OutputChange) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'OutputProperty' struct definition +// Size: 28 +type OutputProperty struct { + Window xproto.Window + Output Output + Atom xproto.Atom + Timestamp xproto.Timestamp + Status byte + // padding: 11 bytes +} + +// Struct read OutputProperty +func OutputPropertyRead(buf []byte, v *OutputProperty) int { + b := 0 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Output = Output(xgb.Get32(buf[b:])) + b += 4 + + v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Status = buf[b] + b += 1 + + b += 11 // padding + + return b +} + +// Struct list read OutputProperty +func OutputPropertyReadList(buf []byte, dest []OutputProperty) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = OutputProperty{} + b += OutputPropertyRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write OutputProperty +func (v OutputProperty) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Atom)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + buf[b] = v.Status + b += 1 + + b += 11 // padding + + return buf +} + +// Write struct list OutputProperty +func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Union definition NotifyDataUnion +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'NotifyDataUnion': +// NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion +// NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion +// NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion +type NotifyDataUnion struct { + Cc CrtcChange + Oc OutputChange + Op OutputProperty +} + +// Union constructor for NotifyDataUnion for field Cc. +func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v +} + +// Union constructor for NotifyDataUnion for field Oc. +func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Oc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v +} + +// Union constructor for NotifyDataUnion for field Op. +func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Op.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v +} + +// Union read NotifyDataUnion +func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { + var b int + + b = 0 // re-read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // re-read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // re-read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return 28 +} + +// Union list read NotifyDataUnion +func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Union write NotifyDataUnion +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v NotifyDataUnion) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + { + structBytes := v.Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return buf +} + +// Union list write NotifyDataUnion +func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + return b +} + +// Event definition ScreenChangeNotify (0) +// Size: 32 + +const ScreenChangeNotify = 0 + +type ScreenChangeNotifyEvent struct { + Sequence uint16 + Rotation byte + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Root xproto.Window + RequestWindow xproto.Window + SizeID uint16 + SubpixelOrder uint16 + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 +} + +// Event read ScreenChangeNotify +func ScreenChangeNotifyEventNew(buf []byte) xgb.Event { + v := ScreenChangeNotifyEvent{} + b := 1 // don't read event number + + v.Rotation = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.RequestWindow = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.SizeID = xgb.Get16(buf[b:]) + b += 2 + + v.SubpixelOrder = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 + + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ScreenChangeNotify +func (v ScreenChangeNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Rotation + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.ConfigTimestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.RequestWindow)) + b += 4 + + xgb.Put16(buf[b:], v.SizeID) + b += 2 + + xgb.Put16(buf[b:], v.SubpixelOrder) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Mwidth) + b += 2 + + xgb.Put16(buf[b:], v.Mheight) + b += 2 + + return buf +} + +func (v ScreenChangeNotifyEvent) ImplementsEvent() {} + +func (v ScreenChangeNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ScreenChangeNotifyEvent) String() string { + fieldVals := make([]string, 0, 11) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Rotation: %d", v.Rotation)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("ConfigTimestamp: %d", v.ConfigTimestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("RequestWindow: %d", v.RequestWindow)) + fieldVals = append(fieldVals, xgb.Sprintf("SizeID: %d", v.SizeID)) + fieldVals = append(fieldVals, xgb.Sprintf("SubpixelOrder: %d", v.SubpixelOrder)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Mwidth: %d", v.Mwidth)) + fieldVals = append(fieldVals, xgb.Sprintf("Mheight: %d", v.Mheight)) + return "ScreenChangeNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew +} + +// Event definition Notify (1) +// Size: 32 + +const Notify = 1 + +type NotifyEvent struct { + Sequence uint16 + SubCode byte + U NotifyDataUnion +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.SubCode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.U = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &v.U) + + return v +} + +// Event write Notify +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.SubCode + b += 1 + + b += 2 // skip sequence number + + { + unionBytes := v.U.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew +} + +// Error definition BadOutput (0) +// Size: 32 + +const BadBadOutput = 0 + +type BadOutputError struct { + Sequence uint16 + NiceName string +} + +// Error read BadOutput +func BadOutputErrorNew(buf []byte) xgb.Error { + v := BadOutputError{} + v.NiceName = "BadOutput" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadOutputError) ImplementsError() {} + +func (err BadOutputError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadOutputError) BadId() uint32 { + return 0 +} + +func (err BadOutputError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +} + +// Error definition BadCrtc (1) +// Size: 32 + +const BadBadCrtc = 1 + +type BadCrtcError struct { + Sequence uint16 + NiceName string +} + +// Error read BadCrtc +func BadCrtcErrorNew(buf []byte) xgb.Error { + v := BadCrtcError{} + v.NiceName = "BadCrtc" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadCrtcError) ImplementsError() {} + +func (err BadCrtcError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadCrtcError) BadId() uint32 { + return 0 +} + +func (err BadCrtcError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadCrtc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +} + +// Error definition BadMode (2) +// Size: 32 + +const BadBadMode = 2 + +type BadModeError struct { + Sequence uint16 + NiceName string +} + +// Error read BadMode +func BadModeErrorNew(buf []byte) xgb.Error { + v := BadModeError{} + v.NiceName = "BadMode" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadModeError) ImplementsError() {} + +func (err BadModeError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadModeError) BadId() uint32 { + return 0 +} + +func (err BadModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), 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, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// Request SetScreenConfig +// size: 24 +type SetScreenConfigCookie struct { + *xgb.Cookie +} + +func SetScreenConfig(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} +} + +func SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} +} + +// Request reply for SetScreenConfig +// size: 32 +type SetScreenConfigReply struct { + Sequence uint16 + Length uint32 + Status byte + NewTimestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Root xproto.Window + SubpixelOrder uint16 + // padding: 10 bytes +} + +// Waits and reads reply data from request SetScreenConfig +func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setScreenConfigReply(buf), nil +} + +// Read reply into structure from buffer for SetScreenConfig +func setScreenConfigReply(buf []byte) *SetScreenConfigReply { + v := new(SetScreenConfigReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NewTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.SubpixelOrder = xgb.Get16(buf[b:]) + b += 2 + + b += 10 // padding + + return v +} + +// Write request to wire for SetScreenConfig +func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + xgb.Put16(buf[b:], SizeID) + b += 2 + + xgb.Put16(buf[b:], Rotation) + b += 2 + + xgb.Put16(buf[b:], Rate) + b += 2 + + b += 2 // padding + + return buf +} + +// Request SelectInput +// size: 12 +type SelectInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectInput +func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{cookie} +} + +func SelectInputChecked(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectInputRequest(c, Window, 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, Window xproto.Window, Enable uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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 + + xgb.Put16(buf[b:], Enable) + b += 2 + + b += 2 // padding + + return buf +} + +// Request GetScreenInfo +// size: 8 +type GetScreenInfoCookie struct { + *xgb.Cookie +} + +func GetScreenInfo(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} +} + +func GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} +} + +// Request reply for GetScreenInfo +// size: ((32 + xgb.Pad((int(NSizes) * 8))) + RefreshRatesListSize(Rates)) +type GetScreenInfoReply struct { + Sequence uint16 + Length uint32 + Rotations byte + Root xproto.Window + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NSizes uint16 + SizeID uint16 + Rotation uint16 + Rate uint16 + NInfo uint16 + // padding: 2 bytes + Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) + Rates []RefreshRates // size: RefreshRatesListSize(Rates) +} + +// Waits and reads reply data from request GetScreenInfo +func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenInfo +func getScreenInfoReply(buf []byte) *GetScreenInfoReply { + v := new(GetScreenInfoReply) + b := 1 // skip reply determinant + + v.Rotations = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NSizes = xgb.Get16(buf[b:]) + b += 2 + + v.SizeID = xgb.Get16(buf[b:]) + b += 2 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rate = xgb.Get16(buf[b:]) + b += 2 + + v.NInfo = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Sizes = make([]ScreenSize, v.NSizes) + b += ScreenSizeReadList(buf[b:], v.Sizes) + + v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes))) + b += RefreshRatesReadList(buf[b:], v.Rates) + + return v +} + +// Write request to wire for GetScreenInfo +func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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(Window)) + b += 4 + + return buf +} + +// Request GetScreenSizeRange +// size: 8 +type GetScreenSizeRangeCookie struct { + *xgb.Cookie +} + +func GetScreenSizeRange(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} +} + +func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} +} + +// Request reply for GetScreenSizeRange +// size: 32 +type GetScreenSizeRangeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MinWidth uint16 + MinHeight uint16 + MaxWidth uint16 + MaxHeight uint16 + // padding: 16 bytes +} + +// Waits and reads reply data from request GetScreenSizeRange +func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenSizeRangeReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenSizeRange +func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { + v := new(GetScreenSizeRangeReply) + 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.MinWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MinHeight = xgb.Get16(buf[b:]) + b += 2 + + v.MaxWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MaxHeight = xgb.Get16(buf[b:]) + b += 2 + + b += 16 // padding + + return v +} + +// Write request to wire for GetScreenSizeRange +func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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 + + return buf +} + +// Request SetScreenSize +// size: 20 +type SetScreenSizeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetScreenSize +func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} +} + +func SetScreenSizeChecked(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} +} + +func (cook SetScreenSizeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetScreenSize +func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], MmWidth) + b += 4 + + xgb.Put32(buf[b:], MmHeight) + b += 4 + + return buf +} + +// Request GetScreenResources +// size: 8 +type GetScreenResourcesCookie struct { + *xgb.Cookie +} + +func GetScreenResources(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} +} + +func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} +} + +// Request reply for GetScreenResources +// size: ((((32 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumModes) * 32))) + xgb.Pad((int(NamesLen) * 1))) +type GetScreenResourcesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NumCrtcs uint16 + NumOutputs uint16 + NumModes uint16 + NamesLen uint16 + // padding: 8 bytes + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) +} + +// Waits and reads reply data from request GetScreenResources +func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenResources +func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { + v := new(GetScreenResourcesReply) + 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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 8 // padding + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Modes = make([]ModeInfo, v.NumModes) + b += ModeInfoReadList(buf[b:], v.Modes) + + v.Names = make([]byte, v.NamesLen) + copy(v.Names[:v.NamesLen], buf[b:]) + b += xgb.Pad(int(v.NamesLen)) + + return v +} + +// Write request to wire for GetScreenResources +func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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 +} + +// Request GetOutputInfo +// size: 12 +type GetOutputInfoCookie struct { + *xgb.Cookie +} + +func GetOutputInfo(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{cookie} +} + +func GetOutputInfoUnchecked(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{cookie} +} + +// Request reply for GetOutputInfo +// size: ((((36 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumModes) * 4))) + xgb.Pad((int(NumClones) * 4))) + xgb.Pad((int(NameLen) * 1))) +type GetOutputInfoReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + Crtc Crtc + MmWidth uint32 + MmHeight uint32 + Connection byte + SubpixelOrder byte + NumCrtcs uint16 + NumModes uint16 + NumPreferred uint16 + NumClones uint16 + NameLen uint16 + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Modes []Mode // size: xgb.Pad((int(NumModes) * 4)) + Clones []Output // size: xgb.Pad((int(NumClones) * 4)) + Name []byte // size: xgb.Pad((int(NameLen) * 1)) +} + +// Waits and reads reply data from request GetOutputInfo +func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetOutputInfo +func getOutputInfoReply(buf []byte) *GetOutputInfoReply { + v := new(GetOutputInfoReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.MmWidth = xgb.Get32(buf[b:]) + b += 4 + + v.MmHeight = xgb.Get32(buf[b:]) + b += 4 + + v.Connection = buf[b] + b += 1 + + v.SubpixelOrder = buf[b] + b += 1 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NumPreferred = xgb.Get16(buf[b:]) + b += 2 + + v.NumClones = xgb.Get16(buf[b:]) + b += 2 + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Modes = make([]Mode, v.NumModes) + for i := 0; i < int(v.NumModes); i++ { + v.Modes[i] = Mode(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Clones = make([]Output, v.NumClones) + for i := 0; i < int(v.NumClones); i++ { + v.Clones[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Name = make([]byte, v.NameLen) + copy(v.Name[:v.NameLen], buf[b:]) + b += xgb.Pad(int(v.NameLen)) + + return v +} + +// Write request to wire for GetOutputInfo +func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + return buf +} + +// Request ListOutputProperties +// size: 8 +type ListOutputPropertiesCookie struct { + *xgb.Cookie +} + +func ListOutputProperties(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} +} + +func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} +} + +// Request reply for ListOutputProperties +// size: (32 + xgb.Pad((int(NumAtoms) * 4))) +type ListOutputPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAtoms uint16 + // padding: 22 bytes + Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) +} + +// Waits and reads reply data from request ListOutputProperties +func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listOutputPropertiesReply(buf), nil +} + +// Read reply into structure from buffer for ListOutputProperties +func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { + v := new(ListOutputPropertiesReply) + 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.NumAtoms = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Atoms = make([]xproto.Atom, v.NumAtoms) + for i := 0; i < int(v.NumAtoms); i++ { + v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for ListOutputProperties +func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + return buf +} + +// Request QueryOutputProperty +// size: 12 +type QueryOutputPropertyCookie struct { + *xgb.Cookie +} + +func QueryOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} +} + +func QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} +} + +// Request reply for QueryOutputProperty +// size: (32 + xgb.Pad((int(Length) * 4))) +type QueryOutputPropertyReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Pending bool + Range bool + Immutable bool + // padding: 21 bytes + ValidValues []int32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request QueryOutputProperty +func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryOutputPropertyReply(buf), nil +} + +// Read reply into structure from buffer for QueryOutputProperty +func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { + v := new(QueryOutputPropertyReply) + 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.Pending = true + } else { + v.Pending = false + } + b += 1 + + if buf[b] == 1 { + v.Range = true + } else { + v.Range = false + } + b += 1 + + if buf[b] == 1 { + v.Immutable = true + } else { + v.Immutable = false + } + b += 1 + + b += 21 // padding + + v.ValidValues = make([]int32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.ValidValues[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryOutputProperty +func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request ConfigureOutputProperty +// size: xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) +type ConfigureOutputPropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for ConfigureOutputProperty +func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} + +func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} + +func (cook ConfigureOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConfigureOutputProperty +func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Range { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ChangeOutputProperty +// size: xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) +type ChangeOutputPropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeOutputProperty +func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} + +func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} + +func (cook ChangeOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeOutputProperty +func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + buf[b] = Mode + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], NumUnits) + b += 4 + + copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) + b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) + + return buf +} + +// Request DeleteOutputProperty +// size: 12 +type DeleteOutputPropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteOutputProperty +func DeleteOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) + return DeleteOutputPropertyCookie{cookie} +} + +func DeleteOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) + return DeleteOutputPropertyCookie{cookie} +} + +func (cook DeleteOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteOutputProperty +func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request GetOutputProperty +// size: 28 +type GetOutputPropertyCookie struct { + *xgb.Cookie +} + +func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} +} + +func GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} +} + +// Request reply for GetOutputProperty +// size: (32 + xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1))) +type GetOutputPropertyReply struct { + Sequence uint16 + Length uint32 + Format byte + Type xproto.Atom + BytesAfter uint32 + NumItems uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) +} + +// Waits and reads reply data from request GetOutputProperty +func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputPropertyReply(buf), nil +} + +// Read reply into structure from buffer for GetOutputProperty +func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { + v := new(GetOutputPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Type = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.NumItems = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) + copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8)))) + + return v +} + +// Write request to wire for GetOutputProperty +func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + return buf +} + +// Request CreateMode +// size: xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) +type CreateModeCookie struct { + *xgb.Cookie +} + +func CreateMode(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} +} + +func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} +} + +// Request reply for CreateMode +// size: 32 +type CreateModeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Mode Mode + // padding: 20 bytes +} + +// Waits and reads reply data from request CreateMode +func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createModeReply(buf), nil +} + +// Read reply into structure from buffer for CreateMode +func createModeReply(buf []byte) *CreateModeReply { + v := new(CreateModeReply) + 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.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for CreateMode +func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + { + structBytes := ModeInfo.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], Name[:len(Name)]) + b += xgb.Pad(int(len(Name))) + + return buf +} + +// Request DestroyMode +// size: 8 +type DestroyModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyMode +func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} +} + +func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} +} + +func (cook DestroyModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyMode +func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// Request AddOutputMode +// size: 12 +type AddOutputModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddOutputMode +func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} +} + +func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} +} + +func (cook AddOutputModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddOutputMode +func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// Request DeleteOutputMode +// size: 12 +type DeleteOutputModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteOutputMode +func DeleteOutputMode(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} +} + +func DeleteOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} +} + +func (cook DeleteOutputModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteOutputMode +func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// Request GetCrtcInfo +// size: 12 +type GetCrtcInfoCookie struct { + *xgb.Cookie +} + +func GetCrtcInfo(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} +} + +func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} +} + +// Request reply for GetCrtcInfo +// size: ((32 + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumPossibleOutputs) * 4))) +type GetCrtcInfoReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + X int16 + Y int16 + Width uint16 + Height uint16 + Mode Mode + Rotation uint16 + Rotations uint16 + NumOutputs uint16 + NumPossibleOutputs uint16 + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) +} + +// Waits and reads reply data from request GetCrtcInfo +func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcInfo +func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { + v := new(GetCrtcInfoReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rotations = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumPossibleOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Possible = make([]Output, v.NumPossibleOutputs) + for i := 0; i < int(v.NumPossibleOutputs); i++ { + v.Possible[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcInfo +func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + return buf +} + +// Request SetCrtcConfig +// size: xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) +type SetCrtcConfigCookie struct { + *xgb.Cookie +} + +func SetCrtcConfig(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} +} + +func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} +} + +// Request reply for SetCrtcConfig +// size: 32 +type SetCrtcConfigReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + // padding: 20 bytes +} + +// Waits and reads reply data from request SetCrtcConfig +func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setCrtcConfigReply(buf), nil +} + +// Read reply into structure from buffer for SetCrtcConfig +func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { + v := new(SetCrtcConfigReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for SetCrtcConfig +func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + xgb.Put16(buf[b:], Rotation) + b += 2 + + b += 2 // padding + + for i := 0; i < int(len(Outputs)); i++ { + xgb.Put32(buf[b:], uint32(Outputs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetCrtcGammaSize +// size: 8 +type GetCrtcGammaSizeCookie struct { + *xgb.Cookie +} + +func GetCrtcGammaSize(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} +} + +func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} +} + +// Request reply for GetCrtcGammaSize +// size: 32 +type GetCrtcGammaSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes +} + +// Waits and reads reply data from request GetCrtcGammaSize +func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcGammaSizeReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcGammaSize +func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { + v := new(GetCrtcGammaSizeReply) + 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.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetCrtcGammaSize +func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request GetCrtcGamma +// size: 8 +type GetCrtcGammaCookie struct { + *xgb.Cookie +} + +func GetCrtcGamma(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} +} + +func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} +} + +// Request reply for GetCrtcGamma +// size: (((32 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) +type GetCrtcGammaReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((int(Size) * 2)) + Green []uint16 // size: xgb.Pad((int(Size) * 2)) + Blue []uint16 // size: xgb.Pad((int(Size) * 2)) +} + +// Waits and reads reply data from request GetCrtcGamma +func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcGammaReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcGamma +func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { + v := new(GetCrtcGammaReply) + 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.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Red = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Green = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Blue = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Blue[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcGamma +func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request SetCrtcGamma +// size: xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) +type SetCrtcGammaCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCrtcGamma +func SetCrtcGamma(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} + +func SetCrtcGammaChecked(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} + +func (cook SetCrtcGammaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCrtcGamma +func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { + size := xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put16(buf[b:], Size) + b += 2 + + b += 2 // padding + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Red[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Green[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Blue[i]) + b += 2 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetScreenResourcesCurrent +// size: 8 +type GetScreenResourcesCurrentCookie struct { + *xgb.Cookie +} + +func GetScreenResourcesCurrent(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} +} + +func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} +} + +// Request reply for GetScreenResourcesCurrent +// size: ((((32 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumModes) * 32))) + xgb.Pad((int(NamesLen) * 1))) +type GetScreenResourcesCurrentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NumCrtcs uint16 + NumOutputs uint16 + NumModes uint16 + NamesLen uint16 + // padding: 8 bytes + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) +} + +// Waits and reads reply data from request GetScreenResourcesCurrent +func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesCurrentReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenResourcesCurrent +func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { + v := new(GetScreenResourcesCurrentReply) + 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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 8 // padding + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Modes = make([]ModeInfo, v.NumModes) + b += ModeInfoReadList(buf[b:], v.Modes) + + v.Names = make([]byte, v.NamesLen) + copy(v.Names[:v.NamesLen], buf[b:]) + b += xgb.Pad(int(v.NamesLen)) + + return v +} + +// Write request to wire for GetScreenResourcesCurrent +func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetCrtcTransform +// size: xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) +type SetCrtcTransformCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCrtcTransform +func SetCrtcTransform(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{cookie} +} + +func SetCrtcTransformChecked(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{cookie} +} + +func (cook SetCrtcTransformCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCrtcTransform +func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) []byte { + size := xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put16(buf[b:], FilterLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], FilterName[:FilterLen]) + b += xgb.Pad(int(FilterLen)) + + for i := 0; i < int(len(FilterParams)); i++ { + xgb.Put32(buf[b:], uint32(FilterParams[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetCrtcTransform +// size: 8 +type GetCrtcTransformCookie struct { + *xgb.Cookie +} + +func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} +} + +func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} +} + +// Request reply for GetCrtcTransform +// size: ((((96 + xgb.Pad((int(PendingLen) * 1))) + xgb.Pad((int(PendingNparams) * 4))) + xgb.Pad((int(CurrentLen) * 1))) + xgb.Pad((int(CurrentNparams) * 4))) +type GetCrtcTransformReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PendingTransform render.Transform + HasTransforms bool + // padding: 3 bytes + CurrentTransform render.Transform + // padding: 4 bytes + PendingLen uint16 + PendingNparams uint16 + CurrentLen uint16 + CurrentNparams uint16 + PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) + PendingParams []render.Fixed // size: xgb.Pad((int(PendingNparams) * 4)) + CurrentFilterName string // size: xgb.Pad((int(CurrentLen) * 1)) + CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) +} + +// Waits and reads reply data from request GetCrtcTransform +func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcTransformReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcTransform +func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { + v := new(GetCrtcTransformReply) + 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.PendingTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.PendingTransform) + + if buf[b] == 1 { + v.HasTransforms = true + } else { + v.HasTransforms = false + } + b += 1 + + b += 3 // padding + + v.CurrentTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.CurrentTransform) + + b += 4 // padding + + v.PendingLen = xgb.Get16(buf[b:]) + b += 2 + + v.PendingNparams = xgb.Get16(buf[b:]) + b += 2 + + v.CurrentLen = xgb.Get16(buf[b:]) + b += 2 + + v.CurrentNparams = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.PendingLen) + copy(byteString[:v.PendingLen], buf[b:]) + v.PendingFilterName = string(byteString) + b += xgb.Pad(int(v.PendingLen)) + } + + v.PendingParams = make([]render.Fixed, v.PendingNparams) + for i := 0; i < int(v.PendingNparams); i++ { + v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + { + byteString := make([]byte, v.CurrentLen) + copy(byteString[:v.CurrentLen], buf[b:]) + v.CurrentFilterName = string(byteString) + b += xgb.Pad(int(v.CurrentLen)) + } + + v.CurrentParams = make([]render.Fixed, v.CurrentNparams) + for i := 0; i < int(v.CurrentNparams); i++ { + v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcTransform +func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request GetPanning +// size: 8 +type GetPanningCookie struct { + *xgb.Cookie +} + +func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} +} + +func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} +} + +// Request reply for GetPanning +// size: 36 +type GetPanningReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + Left uint16 + Top uint16 + Width uint16 + Height uint16 + TrackLeft uint16 + TrackTop uint16 + TrackWidth uint16 + TrackHeight uint16 + BorderLeft int16 + BorderTop int16 + BorderRight int16 + BorderBottom int16 +} + +// Waits and reads reply data from request GetPanning +func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPanningReply(buf), nil +} + +// Read reply into structure from buffer for GetPanning +func getPanningReply(buf []byte) *GetPanningReply { + v := new(GetPanningReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Left = xgb.Get16(buf[b:]) + b += 2 + + v.Top = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.TrackLeft = xgb.Get16(buf[b:]) + b += 2 + + v.TrackTop = xgb.Get16(buf[b:]) + b += 2 + + v.TrackWidth = xgb.Get16(buf[b:]) + b += 2 + + v.TrackHeight = xgb.Get16(buf[b:]) + b += 2 + + v.BorderLeft = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderTop = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderRight = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderBottom = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Write request to wire for GetPanning +func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request SetPanning +// size: 36 +type SetPanningCookie struct { + *xgb.Cookie +} + +func SetPanning(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) + return SetPanningCookie{cookie} +} + +func SetPanningUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) + return SetPanningCookie{cookie} +} + +// Request reply for SetPanning +// size: 12 +type SetPanningReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp +} + +// Waits and reads reply data from request SetPanning +func (cook SetPanningCookie) Reply() (*SetPanningReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setPanningReply(buf), nil +} + +// Read reply into structure from buffer for SetPanning +func setPanningReply(buf []byte) *SetPanningReply { + v := new(SetPanningReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for SetPanning +func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put16(buf[b:], Left) + b += 2 + + xgb.Put16(buf[b:], Top) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], TrackLeft) + b += 2 + + xgb.Put16(buf[b:], TrackTop) + b += 2 + + xgb.Put16(buf[b:], TrackWidth) + b += 2 + + xgb.Put16(buf[b:], TrackHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderLeft)) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderTop)) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderRight)) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderBottom)) + b += 2 + + return buf +} + +// Request SetOutputPrimary +// size: 12 +type SetOutputPrimaryCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetOutputPrimary +func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{cookie} +} + +func SetOutputPrimaryChecked(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{cookie} +} + +func (cook SetOutputPrimaryCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetOutputPrimary +func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + return buf +} + +// Request GetOutputPrimary +// size: 8 +type GetOutputPrimaryCookie struct { + *xgb.Cookie +} + +func GetOutputPrimary(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} +} + +func GetOutputPrimaryUnchecked(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} +} + +// Request reply for GetOutputPrimary +// size: 12 +type GetOutputPrimaryReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Output Output +} + +// Waits and reads reply data from request GetOutputPrimary +func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputPrimaryReply(buf), nil +} + +// Read reply into structure from buffer for GetOutputPrimary +func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { + v := new(GetOutputPrimaryReply) + 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.Output = Output(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetOutputPrimary +func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 31 // 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 +} diff --git a/nexgb/record/record.go b/nexgb/record/record.go new file mode 100644 index 0000000..04d514b --- /dev/null +++ b/nexgb/record/record.go @@ -0,0 +1,1089 @@ +package record + +/* + This file was generated by record.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 RECORD extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "RECORD").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named RECORD could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["RECORD"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["RECORD"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["RECORD"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["RECORD"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["RECORD"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +const ( + HTypeFromServerTime = 1 + HTypeFromClientTime = 2 + HTypeFromClientSequence = 4 +) + +const ( + CsCurrentClients = 1 + CsFutureClients = 2 + CsAllClients = 3 +) + +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 ElementHeader byte + +type ClientSpec uint32 + +// 'Range8' struct definition +// Size: 2 +type Range8 struct { + First byte + Last byte +} + +// Struct read Range8 +func Range8Read(buf []byte, v *Range8) int { + b := 0 + + v.First = buf[b] + b += 1 + + v.Last = buf[b] + b += 1 + + return b +} + +// Struct list read Range8 +func Range8ReadList(buf []byte, dest []Range8) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range8{} + b += Range8Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Range8 +func (v Range8) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.First + b += 1 + + buf[b] = v.Last + b += 1 + + return buf +} + +// Write struct list Range8 +func Range8ListBytes(buf []byte, list []Range8) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Range16' struct definition +// Size: 4 +type Range16 struct { + First uint16 + Last uint16 +} + +// Struct read Range16 +func Range16Read(buf []byte, v *Range16) int { + b := 0 + + v.First = xgb.Get16(buf[b:]) + b += 2 + + v.Last = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Range16 +func Range16ReadList(buf []byte, dest []Range16) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range16{} + b += Range16Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Range16 +func (v Range16) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.First) + b += 2 + + xgb.Put16(buf[b:], v.Last) + b += 2 + + return buf +} + +// Write struct list Range16 +func Range16ListBytes(buf []byte, list []Range16) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ExtRange' struct definition +// Size: 6 +type ExtRange struct { + Major Range8 + Minor Range16 +} + +// Struct read ExtRange +func ExtRangeRead(buf []byte, v *ExtRange) int { + b := 0 + + v.Major = Range8{} + b += Range8Read(buf[b:], &v.Major) + + v.Minor = Range16{} + b += Range16Read(buf[b:], &v.Minor) + + return b +} + +// Struct list read ExtRange +func ExtRangeReadList(buf []byte, dest []ExtRange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ExtRange{} + b += ExtRangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ExtRange +func (v ExtRange) Bytes() []byte { + buf := make([]byte, 6) + b := 0 + + { + structBytes := v.Major.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Minor.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list ExtRange +func ExtRangeListBytes(buf []byte, list []ExtRange) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Range' struct definition +// Size: 24 +type Range struct { + CoreRequests Range8 + CoreReplies Range8 + ExtRequests ExtRange + ExtReplies ExtRange + DeliveredEvents Range8 + DeviceEvents Range8 + Errors Range8 + ClientStarted bool + ClientDied bool +} + +// Struct read Range +func RangeRead(buf []byte, v *Range) int { + b := 0 + + v.CoreRequests = Range8{} + b += Range8Read(buf[b:], &v.CoreRequests) + + v.CoreReplies = Range8{} + b += Range8Read(buf[b:], &v.CoreReplies) + + v.ExtRequests = ExtRange{} + b += ExtRangeRead(buf[b:], &v.ExtRequests) + + v.ExtReplies = ExtRange{} + b += ExtRangeRead(buf[b:], &v.ExtReplies) + + v.DeliveredEvents = Range8{} + b += Range8Read(buf[b:], &v.DeliveredEvents) + + v.DeviceEvents = Range8{} + b += Range8Read(buf[b:], &v.DeviceEvents) + + v.Errors = Range8{} + b += Range8Read(buf[b:], &v.Errors) + + if buf[b] == 1 { + v.ClientStarted = true + } else { + v.ClientStarted = false + } + b += 1 + + if buf[b] == 1 { + v.ClientDied = true + } else { + v.ClientDied = false + } + b += 1 + + return b +} + +// Struct list read Range +func RangeReadList(buf []byte, dest []Range) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range{} + b += RangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Range +func (v Range) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.CoreRequests.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.CoreReplies.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.ExtRequests.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.ExtReplies.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.DeliveredEvents.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.DeviceEvents.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Errors.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + if v.ClientStarted { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if v.ClientDied { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Write struct list Range +func RangeListBytes(buf []byte, list []Range) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ClientInfo' struct definition +// Size: (8 + xgb.Pad((int(NumRanges) * 24))) +type ClientInfo struct { + ClientResource ClientSpec + NumRanges uint32 + Ranges []Range // size: xgb.Pad((int(NumRanges) * 24)) +} + +// Struct read ClientInfo +func ClientInfoRead(buf []byte, v *ClientInfo) int { + b := 0 + + v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) + b += 4 + + v.NumRanges = xgb.Get32(buf[b:]) + b += 4 + + v.Ranges = make([]Range, v.NumRanges) + b += RangeReadList(buf[b:], v.Ranges) + + return b +} + +// Struct list read ClientInfo +func ClientInfoReadList(buf []byte, dest []ClientInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ClientInfo{} + b += ClientInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ClientInfo +func (v ClientInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.ClientResource)) + b += 4 + + xgb.Put32(buf[b:], v.NumRanges) + b += 4 + + b += RangeListBytes(buf[b:], v.Ranges) + + return buf +} + +// Write struct list ClientInfo +func ClientInfoListBytes(buf []byte, list []ClientInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ClientInfo +func ClientInfoListSize(list []ClientInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumRanges) * 24))) + } + return size +} + +// Error definition BadContext (0) +// Size: 32 + +const BadBadContext = 0 + +type BadContextError struct { + Sequence uint16 + NiceName string + InvalidRecord uint32 +} + +// Error read BadContext +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError{} + v.NiceName = "BadContext" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.InvalidRecord = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +func (err BadContextError) ImplementsError() {} + +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextError) BadId() uint32 { + return 0 +} + +func (err BadContextError) Error() string { + fieldVals := make([]string, 0, 1) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("InvalidRecord: %d", err.InvalidRecord)) + return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), 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, MajorVersion uint16, MinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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:], MajorVersion) + b += 2 + + xgb.Put16(buf[b:], MinorVersion) + b += 2 + + return buf +} + +// Request CreateContext +// size: xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +type CreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContext +func CreateContext(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return CreateContextCookie{cookie} +} + +func (cook CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { + size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + buf[b] = byte(ElementHeader) + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + xgb.Put32(buf[b:], NumRanges) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + b += RangeListBytes(buf[b:], Ranges) + + return buf +} + +// Request RegisterClients +// size: xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +type RegisterClientsCookie struct { + *xgb.Cookie +} + +// Write request to wire for RegisterClients +func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return RegisterClientsCookie{cookie} +} + +func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return RegisterClientsCookie{cookie} +} + +func (cook RegisterClientsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RegisterClients +func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { + size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + buf[b] = byte(ElementHeader) + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + xgb.Put32(buf[b:], NumRanges) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + b += RangeListBytes(buf[b:], Ranges) + + return buf +} + +// Request UnregisterClients +// size: xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) +type UnregisterClientsCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnregisterClients +func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) + return UnregisterClientsCookie{cookie} +} + +func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) + return UnregisterClientsCookie{cookie} +} + +func (cook UnregisterClientsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnregisterClients +func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetContext +// size: 8 +type GetContextCookie struct { + *xgb.Cookie +} + +func GetContext(c *xgb.Conn, Context Context) GetContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getContextRequest(c, Context), cookie) + return GetContextCookie{cookie} +} + +func GetContextUnchecked(c *xgb.Conn, Context Context) GetContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getContextRequest(c, Context), cookie) + return GetContextCookie{cookie} +} + +// Request reply for GetContext +// size: (32 + ClientInfoListSize(InterceptedClients)) +type GetContextReply struct { + Sequence uint16 + Length uint32 + Enabled bool + ElementHeader ElementHeader + // padding: 3 bytes + NumInterceptedClients uint32 + // padding: 16 bytes + InterceptedClients []ClientInfo // size: ClientInfoListSize(InterceptedClients) +} + +// Waits and reads reply data from request GetContext +func (cook GetContextCookie) Reply() (*GetContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getContextReply(buf), nil +} + +// Read reply into structure from buffer for GetContext +func getContextReply(buf []byte) *GetContextReply { + v := new(GetContextReply) + 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 + + v.ElementHeader = ElementHeader(buf[b]) + b += 1 + + b += 3 // padding + + v.NumInterceptedClients = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.InterceptedClients = make([]ClientInfo, v.NumInterceptedClients) + b += ClientInfoReadList(buf[b:], v.InterceptedClients) + + return v +} + +// Write request to wire for GetContext +func getContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + return buf +} + +// Request EnableContext +// size: 8 +type EnableContextCookie struct { + *xgb.Cookie +} + +func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(enableContextRequest(c, Context), cookie) + return EnableContextCookie{cookie} +} + +func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(enableContextRequest(c, Context), cookie) + return EnableContextCookie{cookie} +} + +// Request reply for EnableContext +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type EnableContextReply struct { + Sequence uint16 + Length uint32 + Category byte + ElementHeader ElementHeader + ClientSwapped bool + // padding: 2 bytes + XidBase uint32 + ServerTime uint32 + RecSequenceNum uint32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request EnableContext +func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return enableContextReply(buf), nil +} + +// Read reply into structure from buffer for EnableContext +func enableContextReply(buf []byte) *EnableContextReply { + v := new(EnableContextReply) + b := 1 // skip reply determinant + + v.Category = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ElementHeader = ElementHeader(buf[b]) + b += 1 + + if buf[b] == 1 { + v.ClientSwapped = true + } else { + v.ClientSwapped = false + } + b += 1 + + b += 2 // padding + + v.XidBase = xgb.Get32(buf[b:]) + b += 4 + + v.ServerTime = xgb.Get32(buf[b:]) + b += 4 + + v.RecSequenceNum = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for EnableContext +func enableContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + return buf +} + +// Request DisableContext +// size: 8 +type DisableContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DisableContext +func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(disableContextRequest(c, Context), cookie) + return DisableContextCookie{cookie} +} + +func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(disableContextRequest(c, Context), cookie) + return DisableContextCookie{cookie} +} + +func (cook DisableContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DisableContext +func disableContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + return buf +} + +// Request FreeContext +// size: 8 +type FreeContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeContext +func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeContextRequest(c, Context), cookie) + return FreeContextCookie{cookie} +} + +func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeContextRequest(c, Context), cookie) + return FreeContextCookie{cookie} +} + +func (cook FreeContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeContext +func freeContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + return buf +} diff --git a/nexgb/render/render.go b/nexgb/render/render.go new file mode 100644 index 0000000..a939ed9 --- /dev/null +++ b/nexgb/render/render.go @@ -0,0 +1,3542 @@ +package render + +/* + This file was generated by render.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 RENDER extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "RENDER").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named RENDER could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["RENDER"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["RENDER"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["RENDER"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["RENDER"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["RENDER"] = 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 ( + PictTypeIndexed = 0 + PictTypeDirect = 1 +) + +const ( + PictureNone = 0 +) + +const ( + PictOpClear = 0 + PictOpSrc = 1 + PictOpDst = 2 + PictOpOver = 3 + PictOpOverReverse = 4 + PictOpIn = 5 + PictOpInReverse = 6 + PictOpOut = 7 + PictOpOutReverse = 8 + PictOpAtop = 9 + PictOpAtopReverse = 10 + PictOpXor = 11 + PictOpAdd = 12 + PictOpSaturate = 13 + PictOpDisjointClear = 16 + PictOpDisjointSrc = 17 + PictOpDisjointDst = 18 + PictOpDisjointOver = 19 + PictOpDisjointOverReverse = 20 + PictOpDisjointIn = 21 + PictOpDisjointInReverse = 22 + PictOpDisjointOut = 23 + PictOpDisjointOutReverse = 24 + PictOpDisjointAtop = 25 + PictOpDisjointAtopReverse = 26 + PictOpDisjointXor = 27 + PictOpConjointClear = 32 + PictOpConjointSrc = 33 + PictOpConjointDst = 34 + PictOpConjointOver = 35 + PictOpConjointOverReverse = 36 + PictOpConjointIn = 37 + PictOpConjointInReverse = 38 + PictOpConjointOut = 39 + PictOpConjointOutReverse = 40 + PictOpConjointAtop = 41 + PictOpConjointAtopReverse = 42 + PictOpConjointXor = 43 + PictOpMultiply = 48 + PictOpScreen = 49 + PictOpOverlay = 50 + PictOpDarken = 51 + PictOpLighten = 52 + PictOpColorDodge = 53 + PictOpColorBurn = 54 + PictOpHardLight = 55 + PictOpSoftLight = 56 + PictOpDifference = 57 + PictOpExclusion = 58 + PictOpHSLHue = 59 + PictOpHSLSaturation = 60 + PictOpHSLColor = 61 + PictOpHSLLuminosity = 62 +) + +const ( + PolyEdgeSharp = 0 + PolyEdgeSmooth = 1 +) + +const ( + PolyModePrecise = 0 + PolyModeImprecise = 1 +) + +const ( + CpRepeat = 1 + CpAlphaMap = 2 + CpAlphaXOrigin = 4 + CpAlphaYOrigin = 8 + CpClipXOrigin = 16 + CpClipYOrigin = 32 + CpClipMask = 64 + CpGraphicsExposure = 128 + CpSubwindowMode = 256 + CpPolyEdge = 512 + CpPolyMode = 1024 + CpDither = 2048 + CpComponentAlpha = 4096 +) + +const ( + SubPixelUnknown = 0 + SubPixelHorizontalRGB = 1 + SubPixelHorizontalBGR = 2 + SubPixelVerticalRGB = 3 + SubPixelVerticalBGR = 4 + SubPixelNone = 5 +) + +const ( + RepeatNone = 0 + RepeatNormal = 1 + RepeatPad = 2 + RepeatReflect = 3 +) + +type Glyphset uint32 + +func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Glyphset(id), nil +} + +type Picture uint32 + +func NewPictureId(c *xgb.Conn) (Picture, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Picture(id), nil +} + +type Pictformat uint32 + +func NewPictformatId(c *xgb.Conn) (Pictformat, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pictformat(id), nil +} + +type Glyph uint32 + +type Fixed int32 + +// 'Directformat' struct definition +// Size: 16 +type Directformat struct { + RedShift uint16 + RedMask uint16 + GreenShift uint16 + GreenMask uint16 + BlueShift uint16 + BlueMask uint16 + AlphaShift uint16 + AlphaMask uint16 +} + +// Struct read Directformat +func DirectformatRead(buf []byte, v *Directformat) int { + b := 0 + + v.RedShift = xgb.Get16(buf[b:]) + b += 2 + + v.RedMask = xgb.Get16(buf[b:]) + b += 2 + + v.GreenShift = xgb.Get16(buf[b:]) + b += 2 + + v.GreenMask = xgb.Get16(buf[b:]) + b += 2 + + v.BlueShift = xgb.Get16(buf[b:]) + b += 2 + + v.BlueMask = xgb.Get16(buf[b:]) + b += 2 + + v.AlphaShift = xgb.Get16(buf[b:]) + b += 2 + + v.AlphaMask = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Directformat +func DirectformatReadList(buf []byte, dest []Directformat) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Directformat{} + b += DirectformatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Directformat +func (v Directformat) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + xgb.Put16(buf[b:], v.RedShift) + b += 2 + + xgb.Put16(buf[b:], v.RedMask) + b += 2 + + xgb.Put16(buf[b:], v.GreenShift) + b += 2 + + xgb.Put16(buf[b:], v.GreenMask) + b += 2 + + xgb.Put16(buf[b:], v.BlueShift) + b += 2 + + xgb.Put16(buf[b:], v.BlueMask) + b += 2 + + xgb.Put16(buf[b:], v.AlphaShift) + b += 2 + + xgb.Put16(buf[b:], v.AlphaMask) + b += 2 + + return buf +} + +// Write struct list Directformat +func DirectformatListBytes(buf []byte, list []Directformat) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pictforminfo' struct definition +// Size: 28 +type Pictforminfo struct { + Id Pictformat + Type byte + Depth byte + // padding: 2 bytes + Direct Directformat + Colormap xproto.Colormap +} + +// Struct read Pictforminfo +func PictforminfoRead(buf []byte, v *Pictforminfo) int { + b := 0 + + v.Id = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + v.Type = buf[b] + b += 1 + + v.Depth = buf[b] + b += 1 + + b += 2 // padding + + v.Direct = Directformat{} + b += DirectformatRead(buf[b:], &v.Direct) + + v.Colormap = xproto.Colormap(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Pictforminfo +func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictforminfo{} + b += PictforminfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictforminfo +func (v Pictforminfo) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Id)) + b += 4 + + buf[b] = v.Type + b += 1 + + buf[b] = v.Depth + b += 1 + + b += 2 // padding + + { + structBytes := v.Direct.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + return buf +} + +// Write struct list Pictforminfo +func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pictvisual' struct definition +// Size: 8 +type Pictvisual struct { + Visual xproto.Visualid + Format Pictformat +} + +// Struct read Pictvisual +func PictvisualRead(buf []byte, v *Pictvisual) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Format = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Pictvisual +func PictvisualReadList(buf []byte, dest []Pictvisual) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictvisual{} + b += PictvisualRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictvisual +func (v Pictvisual) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Format)) + b += 4 + + return buf +} + +// Write struct list Pictvisual +func PictvisualListBytes(buf []byte, list []Pictvisual) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pictdepth' struct definition +// Size: (8 + xgb.Pad((int(NumVisuals) * 8))) +type Pictdepth struct { + Depth byte + // padding: 1 bytes + NumVisuals uint16 + // padding: 4 bytes + Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8)) +} + +// Struct read Pictdepth +func PictdepthRead(buf []byte, v *Pictdepth) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.NumVisuals = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]Pictvisual, v.NumVisuals) + b += PictvisualReadList(buf[b:], v.Visuals) + + return b +} + +// Struct list read Pictdepth +func PictdepthReadList(buf []byte, dest []Pictdepth) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictdepth{} + b += PictdepthRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictdepth +func (v Pictdepth) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.NumVisuals) + b += 2 + + b += 4 // padding + + b += PictvisualListBytes(buf[b:], v.Visuals) + + return buf +} + +// Write struct list Pictdepth +func PictdepthListBytes(buf []byte, list []Pictdepth) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Pictdepth +func PictdepthListSize(list []Pictdepth) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumVisuals) * 8))) + } + return size +} + +// 'Pictscreen' struct definition +// Size: (8 + PictdepthListSize(Depths)) +type Pictscreen struct { + NumDepths uint32 + Fallback Pictformat + Depths []Pictdepth // size: PictdepthListSize(Depths) +} + +// Struct read Pictscreen +func PictscreenRead(buf []byte, v *Pictscreen) int { + b := 0 + + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.Fallback = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + v.Depths = make([]Pictdepth, v.NumDepths) + b += PictdepthReadList(buf[b:], v.Depths) + + return b +} + +// Struct list read Pictscreen +func PictscreenReadList(buf []byte, dest []Pictscreen) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictscreen{} + b += PictscreenRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictscreen +func (v Pictscreen) Bytes() []byte { + buf := make([]byte, (8 + PictdepthListSize(v.Depths))) + b := 0 + + xgb.Put32(buf[b:], v.NumDepths) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Fallback)) + b += 4 + + b += PictdepthListBytes(buf[b:], v.Depths) + + return buf +} + +// Write struct list Pictscreen +func PictscreenListBytes(buf []byte, list []Pictscreen) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Pictscreen +func PictscreenListSize(list []Pictscreen) int { + size := 0 + for _, item := range list { + size += (8 + PictdepthListSize(item.Depths)) + } + return size +} + +// 'Indexvalue' struct definition +// Size: 12 +type Indexvalue struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +// Struct read Indexvalue +func IndexvalueRead(buf []byte, v *Indexvalue) int { + b := 0 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Indexvalue +func IndexvalueReadList(buf []byte, dest []Indexvalue) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Indexvalue{} + b += IndexvalueRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Indexvalue +func (v Indexvalue) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) + b += 4 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + + return buf +} + +// Write struct list Indexvalue +func IndexvalueListBytes(buf []byte, list []Indexvalue) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Color' struct definition +// Size: 8 +type Color struct { + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +// Struct read Color +func ColorRead(buf []byte, v *Color) int { + b := 0 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Color +func ColorReadList(buf []byte, dest []Color) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Color{} + b += ColorRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Color +func (v Color) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + + return buf +} + +// Write struct list Color +func ColorListBytes(buf []byte, list []Color) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pointfix' struct definition +// Size: 8 +type Pointfix struct { + X Fixed + Y Fixed +} + +// Struct read Pointfix +func PointfixRead(buf []byte, v *Pointfix) int { + b := 0 + + v.X = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Pointfix +func PointfixReadList(buf []byte, dest []Pointfix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pointfix{} + b += PointfixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pointfix +func (v Pointfix) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.X)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 + + return buf +} + +// Write struct list Pointfix +func PointfixListBytes(buf []byte, list []Pointfix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Linefix' struct definition +// Size: 16 +type Linefix struct { + P1 Pointfix + P2 Pointfix +} + +// Struct read Linefix +func LinefixRead(buf []byte, v *Linefix) int { + b := 0 + + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) + + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + return b +} + +// Struct list read Linefix +func LinefixReadList(buf []byte, dest []Linefix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Linefix{} + b += LinefixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Linefix +func (v Linefix) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Linefix +func LinefixListBytes(buf []byte, list []Linefix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Triangle' struct definition +// Size: 24 +type Triangle struct { + P1 Pointfix + P2 Pointfix + P3 Pointfix +} + +// Struct read Triangle +func TriangleRead(buf []byte, v *Triangle) int { + b := 0 + + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) + + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + v.P3 = Pointfix{} + b += PointfixRead(buf[b:], &v.P3) + + return b +} + +// Struct list read Triangle +func TriangleReadList(buf []byte, dest []Triangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Triangle{} + b += TriangleRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Triangle +func (v Triangle) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P3.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Triangle +func TriangleListBytes(buf []byte, list []Triangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Trapezoid' struct definition +// Size: 40 +type Trapezoid struct { + Top Fixed + Bottom Fixed + Left Linefix + Right Linefix +} + +// Struct read Trapezoid +func TrapezoidRead(buf []byte, v *Trapezoid) int { + b := 0 + + v.Top = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Bottom = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Left = Linefix{} + b += LinefixRead(buf[b:], &v.Left) + + v.Right = Linefix{} + b += LinefixRead(buf[b:], &v.Right) + + return b +} + +// Struct list read Trapezoid +func TrapezoidReadList(buf []byte, dest []Trapezoid) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trapezoid{} + b += TrapezoidRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Trapezoid +func (v Trapezoid) Bytes() []byte { + buf := make([]byte, 40) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Top)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Bottom)) + b += 4 + + { + structBytes := v.Left.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Right.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Trapezoid +func TrapezoidListBytes(buf []byte, list []Trapezoid) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Glyphinfo' struct definition +// Size: 12 +type Glyphinfo struct { + Width uint16 + Height uint16 + X int16 + Y int16 + XOff int16 + YOff int16 +} + +// Struct read Glyphinfo +func GlyphinfoRead(buf []byte, v *Glyphinfo) int { + b := 0 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.XOff = int16(xgb.Get16(buf[b:])) + b += 2 + + v.YOff = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Glyphinfo +func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Glyphinfo{} + b += GlyphinfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Glyphinfo +func (v Glyphinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.YOff)) + b += 2 + + return buf +} + +// Write struct list Glyphinfo +func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Transform' struct definition +// Size: 36 +type Transform struct { + Matrix11 Fixed + Matrix12 Fixed + Matrix13 Fixed + Matrix21 Fixed + Matrix22 Fixed + Matrix23 Fixed + Matrix31 Fixed + Matrix32 Fixed + Matrix33 Fixed +} + +// Struct read Transform +func TransformRead(buf []byte, v *Transform) int { + b := 0 + + v.Matrix11 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix12 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix13 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix21 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix22 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix23 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix31 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix32 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix33 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Transform +func TransformReadList(buf []byte, dest []Transform) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Transform{} + b += TransformRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Transform +func (v Transform) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Matrix11)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix12)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix13)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix21)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix22)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix23)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix31)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix32)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix33)) + b += 4 + + return buf +} + +// Write struct list Transform +func TransformListBytes(buf []byte, list []Transform) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Animcursorelt' struct definition +// Size: 8 +type Animcursorelt struct { + Cursor xproto.Cursor + Delay uint32 +} + +// Struct read Animcursorelt +func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { + b := 0 + + v.Cursor = xproto.Cursor(xgb.Get32(buf[b:])) + b += 4 + + v.Delay = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Animcursorelt +func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Animcursorelt{} + b += AnimcursoreltRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Animcursorelt +func (v Animcursorelt) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Cursor)) + b += 4 + + xgb.Put32(buf[b:], v.Delay) + b += 4 + + return buf +} + +// Write struct list Animcursorelt +func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Spanfix' struct definition +// Size: 12 +type Spanfix struct { + L Fixed + R Fixed + Y Fixed +} + +// Struct read Spanfix +func SpanfixRead(buf []byte, v *Spanfix) int { + b := 0 + + v.L = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.R = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Spanfix +func SpanfixReadList(buf []byte, dest []Spanfix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Spanfix{} + b += SpanfixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Spanfix +func (v Spanfix) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], uint32(v.L)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.R)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 + + return buf +} + +// Write struct list Spanfix +func SpanfixListBytes(buf []byte, list []Spanfix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Trap' struct definition +// Size: 24 +type Trap struct { + Top Spanfix + Bot Spanfix +} + +// Struct read Trap +func TrapRead(buf []byte, v *Trap) int { + b := 0 + + v.Top = Spanfix{} + b += SpanfixRead(buf[b:], &v.Top) + + v.Bot = Spanfix{} + b += SpanfixRead(buf[b:], &v.Bot) + + return b +} + +// Struct list read Trap +func TrapReadList(buf []byte, dest []Trap) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trap{} + b += TrapRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Trap +func (v Trap) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.Top.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Bot.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Trap +func TrapListBytes(buf []byte, list []Trap) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Error definition PictFormat (0) +// Size: 32 + +const BadPictFormat = 0 + +type PictFormatError struct { + Sequence uint16 + NiceName string +} + +// Error read PictFormat +func PictFormatErrorNew(buf []byte) xgb.Error { + v := PictFormatError{} + v.NiceName = "PictFormat" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err PictFormatError) ImplementsError() {} + +func (err PictFormatError) SequenceId() uint16 { + return err.Sequence +} + +func (err PictFormatError) BadId() uint32 { + return 0 +} + +func (err PictFormatError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew +} + +// Error definition Picture (1) +// Size: 32 + +const BadPicture = 1 + +type PictureError struct { + Sequence uint16 + NiceName string +} + +// Error read Picture +func PictureErrorNew(buf []byte) xgb.Error { + v := PictureError{} + v.NiceName = "Picture" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err PictureError) ImplementsError() {} + +func (err PictureError) SequenceId() uint16 { + return err.Sequence +} + +func (err PictureError) BadId() uint32 { + return 0 +} + +func (err PictureError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPicture {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew +} + +// Error definition PictOp (2) +// Size: 32 + +const BadPictOp = 2 + +type PictOpError struct { + Sequence uint16 + NiceName string +} + +// Error read PictOp +func PictOpErrorNew(buf []byte) xgb.Error { + v := PictOpError{} + v.NiceName = "PictOp" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err PictOpError) ImplementsError() {} + +func (err PictOpError) SequenceId() uint16 { + return err.Sequence +} + +func (err PictOpError) BadId() uint32 { + return 0 +} + +func (err PictOpError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew +} + +// Error definition GlyphSet (3) +// Size: 32 + +const BadGlyphSet = 3 + +type GlyphSetError struct { + Sequence uint16 + NiceName string +} + +// Error read GlyphSet +func GlyphSetErrorNew(buf []byte) xgb.Error { + v := GlyphSetError{} + v.NiceName = "GlyphSet" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err GlyphSetError) ImplementsError() {} + +func (err GlyphSetError) SequenceId() uint16 { + return err.Sequence +} + +func (err GlyphSetError) BadId() uint32 { + return 0 +} + +func (err GlyphSetError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew +} + +// Error definition Glyph (4) +// Size: 32 + +const BadGlyph = 4 + +type GlyphError struct { + Sequence uint16 + NiceName string +} + +// Error read Glyph +func GlyphErrorNew(buf []byte) xgb.Error { + v := GlyphError{} + v.NiceName = "Glyph" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err GlyphError) ImplementsError() {} + +func (err GlyphError) SequenceId() uint16 { + return err.Sequence +} + +func (err GlyphError) BadId() uint32 { + return 0 +} + +func (err GlyphError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew +} + +// 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["RENDER"] + 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 QueryPictFormats +// size: 4 +type QueryPictFormatsCookie struct { + *xgb.Cookie +} + +func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{cookie} +} + +func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{cookie} +} + +// Request reply for QueryPictFormats +// size: (((32 + xgb.Pad((int(NumFormats) * 28))) + PictscreenListSize(Screens)) + xgb.Pad((int(NumSubpixel) * 4))) +type QueryPictFormatsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFormats uint32 + NumScreens uint32 + NumDepths uint32 + NumVisuals uint32 + NumSubpixel uint32 + // padding: 4 bytes + Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28)) + Screens []Pictscreen // size: PictscreenListSize(Screens) + Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) +} + +// Waits and reads reply data from request QueryPictFormats +func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPictFormatsReply(buf), nil +} + +// Read reply into structure from buffer for QueryPictFormats +func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { + v := new(QueryPictFormatsReply) + 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.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + v.NumScreens = xgb.Get32(buf[b:]) + b += 4 + + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.NumVisuals = xgb.Get32(buf[b:]) + b += 4 + + v.NumSubpixel = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + v.Formats = make([]Pictforminfo, v.NumFormats) + b += PictforminfoReadList(buf[b:], v.Formats) + + v.Screens = make([]Pictscreen, v.NumScreens) + b += PictscreenReadList(buf[b:], v.Screens) + + v.Subpixels = make([]uint32, v.NumSubpixel) + for i := 0; i < int(v.NumSubpixel); i++ { + v.Subpixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryPictFormats +func queryPictFormatsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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 QueryPictIndexValues +// size: 8 +type QueryPictIndexValuesCookie struct { + *xgb.Cookie +} + +func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{cookie} +} + +func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{cookie} +} + +// Request reply for QueryPictIndexValues +// size: (32 + xgb.Pad((int(NumValues) * 12))) +type QueryPictIndexValuesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumValues uint32 + // padding: 20 bytes + Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12)) +} + +// Waits and reads reply data from request QueryPictIndexValues +func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPictIndexValuesReply(buf), nil +} + +// Read reply into structure from buffer for QueryPictIndexValues +func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { + v := new(QueryPictIndexValuesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumValues = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Values = make([]Indexvalue, v.NumValues) + b += IndexvalueReadList(buf[b:], v.Values) + + return v +} + +// Write request to wire for QueryPictIndexValues +func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Format)) + b += 4 + + return buf +} + +// Request CreatePicture +// size: xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreatePictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePicture +func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{cookie} +} + +func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{cookie} +} + +func (cook CreatePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePicture +func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + 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 ChangePicture +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangePictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangePicture +func ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) + return ChangePictureCookie{cookie} +} + +func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) + return ChangePictureCookie{cookie} +} + +func (cook ChangePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangePicture +func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Picture)) + 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 SetPictureClipRectangles +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type SetPictureClipRectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureClipRectangles +func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} +} + +func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} +} + +func (cook SetPictureClipRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureClipRectangles +func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Picture)) + b += 4 + + xgb.Put16(buf[b:], uint16(ClipXOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request FreePicture +// size: 8 +type FreePictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreePicture +func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} +} + +func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} +} + +func (cook FreePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreePicture +func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Picture)) + b += 4 + + return buf +} + +// Request Composite +// size: 36 +type CompositeCookie struct { + *xgb.Cookie +} + +// Write request to wire for Composite +func Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) + return CompositeCookie{cookie} +} + +func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) + return CompositeCookie{cookie} +} + +func (cook CompositeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Composite +func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(MaskX)) + b += 2 + + xgb.Put16(buf[b:], uint16(MaskY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request Trapezoids +// size: xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) +type TrapezoidsCookie struct { + *xgb.Cookie +} + +// Write request to wire for Trapezoids +func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{cookie} +} + +func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{cookie} +} + +func (cook TrapezoidsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Trapezoids +func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += TrapezoidListBytes(buf[b:], Traps) + + return buf +} + +// Request Triangles +// size: xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) +type TrianglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for Triangles +func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{cookie} +} + +func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{cookie} +} + +func (cook TrianglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Triangles +func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += TriangleListBytes(buf[b:], Triangles) + + return buf +} + +// Request TriStrip +// size: xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +type TriStripCookie struct { + *xgb.Cookie +} + +// Write request to wire for TriStrip +func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{cookie} +} + +func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{cookie} +} + +func (cook TriStripCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriStrip +func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += PointfixListBytes(buf[b:], Points) + + return buf +} + +// Request TriFan +// size: xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +type TriFanCookie struct { + *xgb.Cookie +} + +// Write request to wire for TriFan +func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{cookie} +} + +func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{cookie} +} + +func (cook TriFanCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriFan +func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += PointfixListBytes(buf[b:], Points) + + return buf +} + +// Request CreateGlyphSet +// size: 12 +type CreateGlyphSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGlyphSet +func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{cookie} +} + +func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{cookie} +} + +func (cook CreateGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGlyphSet +func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gsid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + return buf +} + +// Request ReferenceGlyphSet +// size: 12 +type ReferenceGlyphSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for ReferenceGlyphSet +func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{cookie} +} + +func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{cookie} +} + +func (cook ReferenceGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ReferenceGlyphSet +func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gsid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Existing)) + b += 4 + + return buf +} + +// Request FreeGlyphSet +// size: 8 +type FreeGlyphSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeGlyphSet +func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} +} + +func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} +} + +func (cook FreeGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGlyphSet +func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + return buf +} + +// Request AddGlyphs +// size: xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) +type AddGlyphsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddGlyphs +func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} +} + +func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} +} + +func (cook AddGlyphsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddGlyphs +func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte { + size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put32(buf[b:], GlyphsLen) + b += 4 + + for i := 0; i < int(GlyphsLen); i++ { + xgb.Put32(buf[b:], Glyphids[i]) + b += 4 + } + b = xgb.Pad(b) + + b += GlyphinfoListBytes(buf[b:], Glyphs) + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request FreeGlyphs +// size: xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) +type FreeGlyphsCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeGlyphs +func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} +} + +func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} +} + +func (cook FreeGlyphsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGlyphs +func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + for i := 0; i < int(len(Glyphs)); i++ { + xgb.Put32(buf[b:], uint32(Glyphs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CompositeGlyphs8 +// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +type CompositeGlyphs8Cookie struct { + *xgb.Cookie +} + +// Write request to wire for CompositeGlyphs8 +func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{cookie} +} + +func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{cookie} +} + +func (cook CompositeGlyphs8Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CompositeGlyphs8 +func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) + + return buf +} + +// Request CompositeGlyphs16 +// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +type CompositeGlyphs16Cookie struct { + *xgb.Cookie +} + +// Write request to wire for CompositeGlyphs16 +func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{cookie} +} + +func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{cookie} +} + +func (cook CompositeGlyphs16Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CompositeGlyphs16 +func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) + + return buf +} + +// Request CompositeGlyphs32 +// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +type CompositeGlyphs32Cookie struct { + *xgb.Cookie +} + +// Write request to wire for CompositeGlyphs32 +func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{cookie} +} + +func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{cookie} +} + +func (cook CompositeGlyphs32Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CompositeGlyphs32 +func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) + + return buf +} + +// Request FillRectangles +// size: xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) +type FillRectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for FillRectangles +func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{cookie} +} + +func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{cookie} +} + +func (cook FillRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FillRectangles +func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte { + size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + b += xproto.RectangleListBytes(buf[b:], Rects) + + return buf +} + +// Request CreateCursor +// size: 16 +type CreateCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateCursor +func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func (cook CreateCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCursor +func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf +} + +// Request SetPictureTransform +// size: 44 +type SetPictureTransformCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureTransform +func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{cookie} +} + +func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{cookie} +} + +func (cook SetPictureTransformCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureTransform +func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte { + size := 44 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request QueryFilters +// size: 8 +type QueryFiltersCookie struct { + *xgb.Cookie +} + +func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} +} + +func QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} +} + +// Request reply for QueryFilters +// size: ((32 + xgb.Pad((int(NumAliases) * 2))) + xproto.StrListSize(Filters)) +type QueryFiltersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAliases uint32 + NumFilters uint32 + // padding: 16 bytes + Aliases []uint16 // size: xgb.Pad((int(NumAliases) * 2)) + Filters []xproto.Str // size: xproto.StrListSize(Filters) +} + +// Waits and reads reply data from request QueryFilters +func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFiltersReply(buf), nil +} + +// Read reply into structure from buffer for QueryFilters +func queryFiltersReply(buf []byte) *QueryFiltersReply { + v := new(QueryFiltersReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAliases = xgb.Get32(buf[b:]) + b += 4 + + v.NumFilters = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Aliases = make([]uint16, v.NumAliases) + for i := 0; i < int(v.NumAliases); i++ { + v.Aliases[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Filters = make([]xproto.Str, v.NumFilters) + b += xproto.StrReadList(buf[b:], v.Filters) + + return v +} + +// Write request to wire for QueryFilters +func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request SetPictureFilter +// size: xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) +type SetPictureFilterCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureFilter +func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{cookie} +} + +func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{cookie} +} + +func (cook SetPictureFilterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureFilter +func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put16(buf[b:], FilterLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Filter[:FilterLen]) + b += xgb.Pad(int(FilterLen)) + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CreateAnimCursor +// size: xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) +type CreateAnimCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateAnimCursor +func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{cookie} +} + +func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{cookie} +} + +func (cook CreateAnimCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateAnimCursor +func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 31 // 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(Cid)) + b += 4 + + b += AnimcursoreltListBytes(buf[b:], Cursors) + + return buf +} + +// Request AddTraps +// size: xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) +type AddTrapsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddTraps +func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{cookie} +} + +func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{cookie} +} + +func (cook AddTrapsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddTraps +func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOff)) + b += 2 + + b += TrapListBytes(buf[b:], Traps) + + return buf +} + +// Request CreateSolidFill +// size: 16 +type CreateSolidFillCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateSolidFill +func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{cookie} +} + +func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{cookie} +} + +func (cook CreateSolidFillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateSolidFill +func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 33 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request CreateLinearGradient +// size: xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +type CreateLinearGradientCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateLinearGradient +func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{cookie} +} + +func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{cookie} +} + +func (cook CreateLinearGradientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateLinearGradient +func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 34 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} + +// Request CreateRadialGradient +// size: xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +type CreateRadialGradientCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRadialGradient +func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{cookie} +} + +func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{cookie} +} + +func (cook CreateRadialGradientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRadialGradient +func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 35 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Inner.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := Outer.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(InnerRadius)) + b += 4 + + xgb.Put32(buf[b:], uint32(OuterRadius)) + b += 4 + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} + +// Request CreateConicalGradient +// size: xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +type CreateConicalGradientCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateConicalGradient +func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{cookie} +} + +func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{cookie} +} + +func (cook CreateConicalGradientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateConicalGradient +func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 36 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Center.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(Angle)) + b += 4 + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} diff --git a/nexgb/res/res.go b/nexgb/res/res.go new file mode 100644 index 0000000..aa958ab --- /dev/null +++ b/nexgb/res/res.go @@ -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 +} diff --git a/nexgb/screensaver/screensaver.go b/nexgb/screensaver/screensaver.go new file mode 100644 index 0000000..d9353f2 --- /dev/null +++ b/nexgb/screensaver/screensaver.go @@ -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 +} diff --git a/nexgb/shape/shape.go b/nexgb/shape/shape.go new file mode 100644 index 0000000..5d9dbf3 --- /dev/null +++ b/nexgb/shape/shape.go @@ -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 +} diff --git a/nexgb/shm/shm.go b/nexgb/shm/shm.go new file mode 100644 index 0000000..ecffafc --- /dev/null +++ b/nexgb/shm/shm.go @@ -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 +} diff --git a/nexgb/sync.go b/nexgb/sync.go new file mode 100644 index 0000000..d671e62 --- /dev/null +++ b/nexgb/sync.go @@ -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 +} diff --git a/nexgb/sync/sync.go b/nexgb/sync/sync.go new file mode 100644 index 0000000..689a5c3 --- /dev/null +++ b/nexgb/sync/sync.go @@ -0,0 +1,1927 @@ +package sync + +/* + This file was generated by sync.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 SYNC extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 4, "SYNC").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named SYNC could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["SYNC"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["SYNC"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["SYNC"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["SYNC"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["SYNC"] = 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' + +const ( + AlarmstateActive = 0 + AlarmstateInactive = 1 + AlarmstateDestroyed = 2 +) + +const ( + TesttypePositiveTransition = 0 + TesttypeNegativeTransition = 1 + TesttypePositiveComparison = 2 + TesttypeNegativeComparison = 3 +) + +const ( + ValuetypeAbsolute = 0 + ValuetypeRelative = 1 +) + +const ( + CaCounter = 1 + CaValueType = 2 + CaValue = 4 + CaTestType = 8 + CaDelta = 16 + CaEvents = 32 +) + +type Alarm uint32 + +func NewAlarmId(c *xgb.Conn) (Alarm, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Alarm(id), nil +} + +type Counter uint32 + +func NewCounterId(c *xgb.Conn) (Counter, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Counter(id), nil +} + +type Fence uint32 + +func NewFenceId(c *xgb.Conn) (Fence, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fence(id), nil +} + +// 'Int64' struct definition +// Size: 8 +type Int64 struct { + Hi int32 + Lo uint32 +} + +// Struct read Int64 +func Int64Read(buf []byte, v *Int64) int { + b := 0 + + v.Hi = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Lo = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Int64 +func Int64ReadList(buf []byte, dest []Int64) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Int64{} + b += Int64Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Int64 +func (v Int64) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Hi)) + b += 4 + + xgb.Put32(buf[b:], v.Lo) + b += 4 + + return buf +} + +// Write struct list Int64 +func Int64ListBytes(buf []byte, list []Int64) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Systemcounter' struct definition +// Size: (14 + xgb.Pad((int(NameLen) * 1))) +type Systemcounter struct { + Counter Counter + Resolution Int64 + NameLen uint16 + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Struct read Systemcounter +func SystemcounterRead(buf []byte, v *Systemcounter) int { + b := 0 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.Resolution = Int64{} + b += Int64Read(buf[b:], &v.Resolution) + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b +} + +// Struct list read Systemcounter +func SystemcounterReadList(buf []byte, dest []Systemcounter) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Systemcounter{} + b += SystemcounterRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Systemcounter +func (v Systemcounter) Bytes() []byte { + buf := make([]byte, (14 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + { + structBytes := v.Resolution.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put16(buf[b:], v.NameLen) + b += 2 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf +} + +// Write struct list Systemcounter +func SystemcounterListBytes(buf []byte, list []Systemcounter) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Systemcounter +func SystemcounterListSize(list []Systemcounter) int { + size := 0 + for _, item := range list { + size += (14 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} + +// 'Trigger' struct definition +// Size: 20 +type Trigger struct { + Counter Counter + WaitType uint32 + WaitValue Int64 + TestType uint32 +} + +// Struct read Trigger +func TriggerRead(buf []byte, v *Trigger) int { + b := 0 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.WaitType = xgb.Get32(buf[b:]) + b += 4 + + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) + + v.TestType = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Trigger +func TriggerReadList(buf []byte, dest []Trigger) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trigger{} + b += TriggerRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Trigger +func (v Trigger) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + xgb.Put32(buf[b:], v.WaitType) + b += 4 + + { + structBytes := v.WaitValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], v.TestType) + b += 4 + + return buf +} + +// Write struct list Trigger +func TriggerListBytes(buf []byte, list []Trigger) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Waitcondition' struct definition +// Size: 28 +type Waitcondition struct { + Trigger Trigger + EventThreshold Int64 +} + +// Struct read Waitcondition +func WaitconditionRead(buf []byte, v *Waitcondition) int { + b := 0 + + v.Trigger = Trigger{} + b += TriggerRead(buf[b:], &v.Trigger) + + v.EventThreshold = Int64{} + b += Int64Read(buf[b:], &v.EventThreshold) + + return b +} + +// Struct list read Waitcondition +func WaitconditionReadList(buf []byte, dest []Waitcondition) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Waitcondition{} + b += WaitconditionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Waitcondition +func (v Waitcondition) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + { + structBytes := v.Trigger.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.EventThreshold.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Waitcondition +func WaitconditionListBytes(buf []byte, list []Waitcondition) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Event definition CounterNotify (0) +// Size: 32 + +const CounterNotify = 0 + +type CounterNotifyEvent struct { + Sequence uint16 + Kind byte + Counter Counter + WaitValue Int64 + CounterValue Int64 + Timestamp xproto.Timestamp + Count uint16 + Destroyed bool + // padding: 1 bytes +} + +// Event read CounterNotify +func CounterNotifyEventNew(buf []byte) xgb.Event { + v := CounterNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.Destroyed = true + } else { + v.Destroyed = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write CounterNotify +func (v CounterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + { + structBytes := v.WaitValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + if v.Destroyed { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v CounterNotifyEvent) ImplementsEvent() {} + +func (v CounterNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CounterNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Counter: %d", v.Counter)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Destroyed: %t", v.Destroyed)) + return "CounterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew +} + +// Event definition AlarmNotify (1) +// Size: 32 + +const AlarmNotify = 1 + +type AlarmNotifyEvent struct { + Sequence uint16 + Kind byte + Alarm Alarm + CounterValue Int64 + AlarmValue Int64 + Timestamp xproto.Timestamp + State byte + // padding: 3 bytes +} + +// Event read AlarmNotify +func AlarmNotifyEventNew(buf []byte) xgb.Event { + v := AlarmNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Alarm = Alarm(xgb.Get32(buf[b:])) + b += 4 + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.AlarmValue = Int64{} + b += Int64Read(buf[b:], &v.AlarmValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write AlarmNotify +func (v AlarmNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Alarm)) + b += 4 + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.AlarmValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v AlarmNotifyEvent) ImplementsEvent() {} + +func (v AlarmNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v AlarmNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Alarm: %d", v.Alarm)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "AlarmNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +} + +// Error definition Counter (0) +// Size: 32 + +const BadCounter = 0 + +type CounterError struct { + Sequence uint16 + NiceName string + BadCounter uint32 + MinorOpcode uint16 + MajorOpcode byte +} + +// Error read Counter +func CounterErrorNew(buf []byte) xgb.Error { + v := CounterError{} + v.NiceName = "Counter" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadCounter = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + return v +} + +func (err CounterError) ImplementsError() {} + +func (err CounterError) SequenceId() uint16 { + return err.Sequence +} + +func (err CounterError) BadId() uint32 { + return 0 +} + +func (err CounterError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadCounter: %d", err.BadCounter)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCounter {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew +} + +// Error definition Alarm (1) +// Size: 32 + +const BadAlarm = 1 + +type AlarmError struct { + Sequence uint16 + NiceName string + BadAlarm uint32 + MinorOpcode uint16 + MajorOpcode byte +} + +// Error read Alarm +func AlarmErrorNew(buf []byte) xgb.Error { + v := AlarmError{} + v.NiceName = "Alarm" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadAlarm = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + return v +} + +func (err AlarmError) ImplementsError() {} + +func (err AlarmError) SequenceId() uint16 { + return err.Sequence +} + +func (err AlarmError) BadId() uint32 { + return 0 +} + +func (err AlarmError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadAlarm: %d", err.BadAlarm)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlarm {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew +} + +// Request Initialize +// size: 8 +type InitializeCookie struct { + *xgb.Cookie +} + +func Initialize(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) + return InitializeCookie{cookie} +} + +func InitializeUnchecked(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) + return InitializeCookie{cookie} +} + +// Request reply for Initialize +// size: 32 +type InitializeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion byte + MinorVersion byte + // padding: 22 bytes +} + +// Waits and reads reply data from request Initialize +func (cook InitializeCookie) Reply() (*InitializeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return initializeReply(buf), nil +} + +// Read reply into structure from buffer for Initialize +func initializeReply(buf []byte) *InitializeReply { + v := new(InitializeReply) + 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 = buf[b] + b += 1 + + v.MinorVersion = buf[b] + b += 1 + + b += 22 // padding + + return v +} + +// Write request to wire for Initialize +func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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] = DesiredMajorVersion + b += 1 + + buf[b] = DesiredMinorVersion + b += 1 + + return buf +} + +// Request ListSystemCounters +// size: 4 +type ListSystemCountersCookie struct { + *xgb.Cookie +} + +func ListSystemCounters(c *xgb.Conn) ListSystemCountersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listSystemCountersRequest(c), cookie) + return ListSystemCountersCookie{cookie} +} + +func ListSystemCountersUnchecked(c *xgb.Conn) ListSystemCountersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listSystemCountersRequest(c), cookie) + return ListSystemCountersCookie{cookie} +} + +// Request reply for ListSystemCounters +// size: (32 + SystemcounterListSize(Counters)) +type ListSystemCountersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CountersLen uint32 + // padding: 20 bytes + Counters []Systemcounter // size: SystemcounterListSize(Counters) +} + +// Waits and reads reply data from request ListSystemCounters +func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSystemCountersReply(buf), nil +} + +// Read reply into structure from buffer for ListSystemCounters +func listSystemCountersReply(buf []byte) *ListSystemCountersReply { + v := new(ListSystemCountersReply) + 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.CountersLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Counters = make([]Systemcounter, v.CountersLen) + b += SystemcounterReadList(buf[b:], v.Counters) + + return v +} + +// Write request to wire for ListSystemCounters +func listSystemCountersRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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 CreateCounter +// size: 16 +type CreateCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateCounter +func CreateCounter(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) + return CreateCounterCookie{cookie} +} + +func CreateCounterChecked(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) + return CreateCounterCookie{cookie} +} + +func (cook CreateCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCounter +func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Id)) + b += 4 + + { + structBytes := InitialValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request DestroyCounter +// size: 8 +type DestroyCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyCounter +func DestroyCounter(c *xgb.Conn, Counter Counter) DestroyCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyCounterRequest(c, Counter), cookie) + return DestroyCounterCookie{cookie} +} + +func DestroyCounterChecked(c *xgb.Conn, Counter Counter) DestroyCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyCounterRequest(c, Counter), cookie) + return DestroyCounterCookie{cookie} +} + +func (cook DestroyCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyCounter +func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Counter)) + b += 4 + + return buf +} + +// Request QueryCounter +// size: 8 +type QueryCounterCookie struct { + *xgb.Cookie +} + +func QueryCounter(c *xgb.Conn, Counter Counter) QueryCounterCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryCounterRequest(c, Counter), cookie) + return QueryCounterCookie{cookie} +} + +func QueryCounterUnchecked(c *xgb.Conn, Counter Counter) QueryCounterCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryCounterRequest(c, Counter), cookie) + return QueryCounterCookie{cookie} +} + +// Request reply for QueryCounter +// size: 16 +type QueryCounterReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CounterValue Int64 +} + +// Waits and reads reply data from request QueryCounter +func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryCounterReply(buf), nil +} + +// Read reply into structure from buffer for QueryCounter +func queryCounterReply(buf []byte) *QueryCounterReply { + v := new(QueryCounterReply) + 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.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + return v +} + +// Write request to wire for QueryCounter +func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Counter)) + b += 4 + + return buf +} + +// Request Await +// size: xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) +type AwaitCookie struct { + *xgb.Cookie +} + +// Write request to wire for Await +func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} +} + +func AwaitChecked(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} +} + +func (cook AwaitCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Await +func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { + size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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 + + b += WaitconditionListBytes(buf[b:], WaitList) + + return buf +} + +// Request ChangeCounter +// size: 16 +type ChangeCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeCounter +func ChangeCounter(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} +} + +func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} +} + +func (cook ChangeCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCounter +func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Counter)) + b += 4 + + { + structBytes := Amount.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request SetCounter +// size: 16 +type SetCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCounter +func SetCounter(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCounterRequest(c, Counter, Value), cookie) + return SetCounterCookie{cookie} +} + +func SetCounterChecked(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCounterRequest(c, Counter, Value), cookie) + return SetCounterCookie{cookie} +} + +func (cook SetCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCounter +func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Counter)) + b += 4 + + { + structBytes := Value.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request CreateAlarm +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreateAlarmCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateAlarm +func CreateAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{cookie} +} + +func CreateAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{cookie} +} + +func (cook CreateAlarmCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateAlarm +func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Id)) + 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 ChangeAlarm +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeAlarmCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeAlarm +func ChangeAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return ChangeAlarmCookie{cookie} +} + +func ChangeAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return ChangeAlarmCookie{cookie} +} + +func (cook ChangeAlarmCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeAlarm +func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Id)) + 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 DestroyAlarm +// size: 8 +type DestroyAlarmCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyAlarm +func DestroyAlarm(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) + return DestroyAlarmCookie{cookie} +} + +func DestroyAlarmChecked(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) + return DestroyAlarmCookie{cookie} +} + +func (cook DestroyAlarmCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyAlarm +func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Alarm)) + b += 4 + + return buf +} + +// Request QueryAlarm +// size: 8 +type QueryAlarmCookie struct { + *xgb.Cookie +} + +func QueryAlarm(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryAlarmRequest(c, Alarm), cookie) + return QueryAlarmCookie{cookie} +} + +func QueryAlarmUnchecked(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryAlarmRequest(c, Alarm), cookie) + return QueryAlarmCookie{cookie} +} + +// Request reply for QueryAlarm +// size: 40 +type QueryAlarmReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Trigger Trigger + Delta Int64 + Events bool + State byte + // padding: 2 bytes +} + +// Waits and reads reply data from request QueryAlarm +func (cook QueryAlarmCookie) Reply() (*QueryAlarmReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryAlarmReply(buf), nil +} + +// Read reply into structure from buffer for QueryAlarm +func queryAlarmReply(buf []byte) *QueryAlarmReply { + v := new(QueryAlarmReply) + 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.Trigger = Trigger{} + b += TriggerRead(buf[b:], &v.Trigger) + + v.Delta = Int64{} + b += Int64Read(buf[b:], &v.Delta) + + if buf[b] == 1 { + v.Events = true + } else { + v.Events = false + } + b += 1 + + v.State = buf[b] + b += 1 + + b += 2 // padding + + return v +} + +// Write request to wire for QueryAlarm +func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Alarm)) + b += 4 + + return buf +} + +// Request SetPriority +// size: 12 +type SetPriorityCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPriority +func SetPriority(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) + return SetPriorityCookie{cookie} +} + +func SetPriorityChecked(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) + return SetPriorityCookie{cookie} +} + +func (cook SetPriorityCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPriority +func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], uint32(Priority)) + b += 4 + + return buf +} + +// Request GetPriority +// size: 8 +type GetPriorityCookie struct { + *xgb.Cookie +} + +func GetPriority(c *xgb.Conn, Id uint32) GetPriorityCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPriorityRequest(c, Id), cookie) + return GetPriorityCookie{cookie} +} + +func GetPriorityUnchecked(c *xgb.Conn, Id uint32) GetPriorityCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPriorityRequest(c, Id), cookie) + return GetPriorityCookie{cookie} +} + +// Request reply for GetPriority +// size: 12 +type GetPriorityReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Priority int32 +} + +// Waits and reads reply data from request GetPriority +func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPriorityReply(buf), nil +} + +// Read reply into structure from buffer for GetPriority +func getPriorityReply(buf []byte) *GetPriorityReply { + v := new(GetPriorityReply) + 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.Priority = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetPriority +func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Id) + b += 4 + + return buf +} + +// Request CreateFence +// size: 16 +type CreateFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateFence +func CreateFence(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) + return CreateFenceCookie{cookie} +} + +func CreateFenceChecked(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) + return CreateFenceCookie{cookie} +} + +func (cook CreateFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateFence +func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + if InitiallyTriggered { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request TriggerFence +// size: 8 +type TriggerFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for TriggerFence +func TriggerFence(c *xgb.Conn, Fence Fence) TriggerFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(triggerFenceRequest(c, Fence), cookie) + return TriggerFenceCookie{cookie} +} + +func TriggerFenceChecked(c *xgb.Conn, Fence Fence) TriggerFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(triggerFenceRequest(c, Fence), cookie) + return TriggerFenceCookie{cookie} +} + +func (cook TriggerFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriggerFence +func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request ResetFence +// size: 8 +type ResetFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for ResetFence +func ResetFence(c *xgb.Conn, Fence Fence) ResetFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(resetFenceRequest(c, Fence), cookie) + return ResetFenceCookie{cookie} +} + +func ResetFenceChecked(c *xgb.Conn, Fence Fence) ResetFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(resetFenceRequest(c, Fence), cookie) + return ResetFenceCookie{cookie} +} + +func (cook ResetFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ResetFence +func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request DestroyFence +// size: 8 +type DestroyFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyFence +func DestroyFence(c *xgb.Conn, Fence Fence) DestroyFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyFenceRequest(c, Fence), cookie) + return DestroyFenceCookie{cookie} +} + +func DestroyFenceChecked(c *xgb.Conn, Fence Fence) DestroyFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyFenceRequest(c, Fence), cookie) + return DestroyFenceCookie{cookie} +} + +func (cook DestroyFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyFence +func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request QueryFence +// size: 8 +type QueryFenceCookie struct { + *xgb.Cookie +} + +func QueryFence(c *xgb.Conn, Fence Fence) QueryFenceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFenceRequest(c, Fence), cookie) + return QueryFenceCookie{cookie} +} + +func QueryFenceUnchecked(c *xgb.Conn, Fence Fence) QueryFenceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFenceRequest(c, Fence), cookie) + return QueryFenceCookie{cookie} +} + +// Request reply for QueryFence +// size: 32 +type QueryFenceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Triggered bool + // padding: 23 bytes +} + +// Waits and reads reply data from request QueryFence +func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFenceReply(buf), nil +} + +// Read reply into structure from buffer for QueryFence +func queryFenceReply(buf []byte) *QueryFenceReply { + v := new(QueryFenceReply) + 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.Triggered = true + } else { + v.Triggered = false + } + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for QueryFence +func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request AwaitFence +// size: xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) +type AwaitFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for AwaitFence +func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} +} + +func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} +} + +func (cook AwaitFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AwaitFence +func awaitFenceRequest(c *xgb.Conn, FenceList []Fence) []byte { + size := xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + for i := 0; i < int(len(FenceList)); i++ { + xgb.Put32(buf[b:], uint32(FenceList[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go new file mode 100644 index 0000000..324d455 --- /dev/null +++ b/nexgb/xcmisc/xcmisc.go @@ -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 +} diff --git a/nexgb/xevie/xevie.go b/nexgb/xevie/xevie.go new file mode 100644 index 0000000..c3943f9 --- /dev/null +++ b/nexgb/xevie/xevie.go @@ -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 +} diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go new file mode 100644 index 0000000..0259729 --- /dev/null +++ b/nexgb/xf86dri/xf86dri.go @@ -0,0 +1,1121 @@ +package xf86dri + +/* + This file was generated by xf86dri.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 XFree86-DRI extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 11, "XFree86-DRI").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFree86-DRI"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFree86-DRI"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFree86-DRI"] = 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' + +// 'DrmClipRect' struct definition +// Size: 8 +type DrmClipRect struct { + X1 int16 + Y1 int16 + X2 int16 + X3 int16 +} + +// Struct read DrmClipRect +func DrmClipRectRead(buf []byte, v *DrmClipRect) int { + b := 0 + + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X3 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read DrmClipRect +func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DrmClipRect{} + b += DrmClipRectRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DrmClipRect +func (v DrmClipRect) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X2)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X3)) + b += 2 + + return buf +} + +// Write struct list DrmClipRect +func DrmClipRectListBytes(buf []byte, list []DrmClipRect) 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 + DriMajorVersion uint16 + DriMinorVersion uint16 + DriMinorPatch 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.DriMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorPatch = 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["XFREE86-DRI"] + 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 QueryDirectRenderingCapable +// size: 8 +type QueryDirectRenderingCapableCookie struct { + *xgb.Cookie +} + +func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} +} + +func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} +} + +// Request reply for QueryDirectRenderingCapable +// size: 9 +type QueryDirectRenderingCapableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IsCapable bool +} + +// Waits and reads reply data from request QueryDirectRenderingCapable +func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryDirectRenderingCapableReply(buf), nil +} + +// Read reply into structure from buffer for QueryDirectRenderingCapable +func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { + v := new(QueryDirectRenderingCapableReply) + 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.IsCapable = true + } else { + v.IsCapable = false + } + b += 1 + + return v +} + +// Write request to wire for QueryDirectRenderingCapable +func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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 OpenConnection +// size: 8 +type OpenConnectionCookie struct { + *xgb.Cookie +} + +func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} +} + +func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} +} + +// Request reply for OpenConnection +// size: (32 + xgb.Pad((int(BusIdLen) * 1))) +type OpenConnectionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SareaHandleLow uint32 + SareaHandleHigh uint32 + BusIdLen uint32 + // padding: 12 bytes + BusId string // size: xgb.Pad((int(BusIdLen) * 1)) +} + +// Waits and reads reply data from request OpenConnection +func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return openConnectionReply(buf), nil +} + +// Read reply into structure from buffer for OpenConnection +func openConnectionReply(buf []byte) *OpenConnectionReply { + v := new(OpenConnectionReply) + 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.SareaHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.SareaHandleHigh = xgb.Get32(buf[b:]) + b += 4 + + v.BusIdLen = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + { + byteString := make([]byte, v.BusIdLen) + copy(byteString[:v.BusIdLen], buf[b:]) + v.BusId = string(byteString) + b += xgb.Pad(int(v.BusIdLen)) + } + + return v +} + +// Write request to wire for OpenConnection +func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + return buf +} + +// Request CloseConnection +// size: 8 +type CloseConnectionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseConnection +func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} +} + +func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} +} + +func (cook CloseConnectionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseConnection +func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + return buf +} + +// Request GetClientDriverName +// size: 8 +type GetClientDriverNameCookie struct { + *xgb.Cookie +} + +func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} +} + +func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} +} + +// Request reply for GetClientDriverName +// size: (32 + xgb.Pad((int(ClientDriverNameLen) * 1))) +type GetClientDriverNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ClientDriverMajorVersion uint32 + ClientDriverMinorVersion uint32 + ClientDriverPatchVersion uint32 + ClientDriverNameLen uint32 + // padding: 8 bytes + ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) +} + +// Waits and reads reply data from request GetClientDriverName +func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClientDriverNameReply(buf), nil +} + +// Read reply into structure from buffer for GetClientDriverName +func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { + v := new(GetClientDriverNameReply) + 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.ClientDriverMajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverNameLen = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + { + byteString := make([]byte, v.ClientDriverNameLen) + copy(byteString[:v.ClientDriverNameLen], buf[b:]) + v.ClientDriverName = string(byteString) + b += xgb.Pad(int(v.ClientDriverNameLen)) + } + + return v +} + +// Write request to wire for GetClientDriverName +func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + return buf +} + +// Request CreateContext +// size: 16 +type CreateContextCookie struct { + *xgb.Cookie +} + +func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +// Request reply for CreateContext +// size: 12 +type CreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + HwContext uint32 +} + +// 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.HwContext = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], Visual) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request DestroyContext +// size: 12 +type DestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyContext +func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request CreateDrawable +// size: 12 +type CreateDrawableCookie struct { + *xgb.Cookie +} + +func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +// Request reply for CreateDrawable +// size: 12 +type CreateDrawableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + HwDrawableHandle uint32 +} + +// Waits and reads reply data from request CreateDrawable +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createDrawableReply(buf), nil +} + +// Read reply into structure from buffer for CreateDrawable +func createDrawableReply(buf []byte) *CreateDrawableReply { + v := new(CreateDrawableReply) + 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.HwDrawableHandle = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for CreateDrawable +func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request DestroyDrawable +// size: 12 +type DestroyDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyDrawable +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func (cook DestroyDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyDrawable +func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request GetDrawableInfo +// size: 12 +type GetDrawableInfoCookie struct { + *xgb.Cookie +} + +func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) + return GetDrawableInfoCookie{cookie} +} + +func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) + return GetDrawableInfoCookie{cookie} +} + +// Request reply for GetDrawableInfo +// size: ((36 + xgb.Pad((int(NumClipRects) * 8))) + xgb.Pad((int(NumBackClipRects) * 8))) +type GetDrawableInfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DrawableTableIndex uint32 + DrawableTableStamp uint32 + DrawableOriginX int16 + DrawableOriginY int16 + DrawableSizeW int16 + DrawableSizeH int16 + NumClipRects uint32 + BackX int16 + BackY int16 + NumBackClipRects uint32 + ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) + BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) +} + +// Waits and reads reply data from request GetDrawableInfo +func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetDrawableInfo +func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { + v := new(GetDrawableInfoReply) + 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.DrawableTableIndex = xgb.Get32(buf[b:]) + b += 4 + + v.DrawableTableStamp = xgb.Get32(buf[b:]) + b += 4 + + v.DrawableOriginX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableOriginY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableSizeW = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableSizeH = int16(xgb.Get16(buf[b:])) + b += 2 + + v.NumClipRects = xgb.Get32(buf[b:]) + b += 4 + + v.BackX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BackY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.NumBackClipRects = xgb.Get32(buf[b:]) + b += 4 + + v.ClipRects = make([]DrmClipRect, v.NumClipRects) + b += DrmClipRectReadList(buf[b:], v.ClipRects) + + v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) + b += DrmClipRectReadList(buf[b:], v.BackClipRects) + + return v +} + +// Write request to wire for GetDrawableInfo +func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request GetDeviceInfo +// size: 8 +type GetDeviceInfoCookie struct { + *xgb.Cookie +} + +func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} +} + +func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} +} + +// Request reply for GetDeviceInfo +// size: (32 + xgb.Pad((int(DevicePrivateSize) * 4))) +type GetDeviceInfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + FramebufferHandleLow uint32 + FramebufferHandleHigh uint32 + FramebufferOriginOffset uint32 + FramebufferSize uint32 + FramebufferStride uint32 + DevicePrivateSize uint32 + DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) +} + +// Waits and reads reply data from request GetDeviceInfo +func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceInfo +func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { + v := new(GetDeviceInfoReply) + 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.FramebufferHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferHandleHigh = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferStride = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivateSize = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivate = make([]uint32, v.DevicePrivateSize) + for i := 0; i < int(v.DevicePrivateSize); i++ { + v.DevicePrivate[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceInfo +func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request AuthConnection +// size: 12 +type AuthConnectionCookie struct { + *xgb.Cookie +} + +func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} +} + +func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} +} + +// Request reply for AuthConnection +// size: 12 +type AuthConnectionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Authenticated uint32 +} + +// Waits and reads reply data from request AuthConnection +func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return authConnectionReply(buf), nil +} + +// Read reply into structure from buffer for AuthConnection +func authConnectionReply(buf []byte) *AuthConnectionReply { + v := new(AuthConnectionReply) + 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.Authenticated = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for AuthConnection +func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Magic) + b += 4 + + return buf +} diff --git a/nexgb/xf86vidmode/xf86vidmode.go b/nexgb/xf86vidmode/xf86vidmode.go new file mode 100644 index 0000000..4137df8 --- /dev/null +++ b/nexgb/xf86vidmode/xf86vidmode.go @@ -0,0 +1,2360 @@ +package xf86vidmode + +/* + This file was generated by xf86vidmode.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 XFree86-VidModeExtension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 24, "XFree86-VidModeExtension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFree86-VidModeExtension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFree86-VidModeExtension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFree86-VidModeExtension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFree86-VidModeExtension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] = 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 ( + ModeFlagPositiveHsync = 1 + ModeFlagNegativeHsync = 2 + ModeFlagPositiveVsync = 4 + ModeFlagNegativeVsync = 8 + ModeFlagInterlace = 16 + ModeFlagCompositeSync = 32 + ModeFlagPositiveCsync = 64 + ModeFlagNegativeCsync = 128 + ModeFlagHSkew = 256 + ModeFlagBroadcast = 512 + ModeFlagPixmux = 1024 + ModeFlagDoubleClock = 2048 + ModeFlagHalfClock = 4096 +) + +const ( + ClockFlagProgramable = 1 +) + +const ( + PermissionRead = 1 + PermissionWrite = 2 +) + +type Syncrange uint32 + +type Dotclock uint32 + +// 'ModeInfo' struct definition +// Size: 48 +type ModeInfo struct { + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint32 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 4 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 +} + +// Struct read ModeInfo +func ModeInfoRead(buf []byte, v *ModeInfo) int { + b := 0 + + v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + b += 4 + + v.Hdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get32(buf[b:]) + b += 4 + + v.Vdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Privsize = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read ModeInfo +func ModeInfoReadList(buf []byte, dest []ModeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ModeInfo{} + b += ModeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ModeInfo +func (v ModeInfo) Bytes() []byte { + buf := make([]byte, 48) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Dotclock)) + b += 4 + + xgb.Put16(buf[b:], v.Hdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Htotal) + b += 2 + + xgb.Put32(buf[b:], v.Hskew) + b += 4 + + xgb.Put16(buf[b:], v.Vdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Vtotal) + b += 2 + + b += 4 // padding + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], v.Privsize) + b += 4 + + return buf +} + +// Write struct list ModeInfo +func ModeInfoListBytes(buf []byte, list []ModeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Error definition BadClock (0) +// Size: 32 + +const BadBadClock = 0 + +type BadClockError struct { + Sequence uint16 + NiceName string +} + +// Error read BadClock +func BadClockErrorNew(buf []byte) xgb.Error { + v := BadClockError{} + v.NiceName = "BadClock" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadClockError) ImplementsError() {} + +func (err BadClockError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadClockError) BadId() uint32 { + return 0 +} + +func (err BadClockError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadClock {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][0] = BadClockErrorNew +} + +// Error definition BadHTimings (1) +// Size: 32 + +const BadBadHTimings = 1 + +type BadHTimingsError struct { + Sequence uint16 + NiceName string +} + +// Error read BadHTimings +func BadHTimingsErrorNew(buf []byte) xgb.Error { + v := BadHTimingsError{} + v.NiceName = "BadHTimings" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadHTimingsError) ImplementsError() {} + +func (err BadHTimingsError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadHTimingsError) BadId() uint32 { + return 0 +} + +func (err BadHTimingsError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadHTimings {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][1] = BadHTimingsErrorNew +} + +// Error definition BadVTimings (2) +// Size: 32 + +const BadBadVTimings = 2 + +type BadVTimingsError struct { + Sequence uint16 + NiceName string +} + +// Error read BadVTimings +func BadVTimingsErrorNew(buf []byte) xgb.Error { + v := BadVTimingsError{} + v.NiceName = "BadVTimings" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadVTimingsError) ImplementsError() {} + +func (err BadVTimingsError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadVTimingsError) BadId() uint32 { + return 0 +} + +func (err BadVTimingsError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadVTimings {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][2] = BadVTimingsErrorNew +} + +// Error definition ModeUnsuitable (3) +// Size: 32 + +const BadModeUnsuitable = 3 + +type ModeUnsuitableError struct { + Sequence uint16 + NiceName string +} + +// Error read ModeUnsuitable +func ModeUnsuitableErrorNew(buf []byte) xgb.Error { + v := ModeUnsuitableError{} + v.NiceName = "ModeUnsuitable" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ModeUnsuitableError) ImplementsError() {} + +func (err ModeUnsuitableError) SequenceId() uint16 { + return err.Sequence +} + +func (err ModeUnsuitableError) BadId() uint32 { + return 0 +} + +func (err ModeUnsuitableError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadModeUnsuitable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew +} + +// Error definition ExtensionDisabled (4) +// Size: 32 + +const BadExtensionDisabled = 4 + +type ExtensionDisabledError struct { + Sequence uint16 + NiceName string +} + +// Error read ExtensionDisabled +func ExtensionDisabledErrorNew(buf []byte) xgb.Error { + v := ExtensionDisabledError{} + v.NiceName = "ExtensionDisabled" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ExtensionDisabledError) ImplementsError() {} + +func (err ExtensionDisabledError) SequenceId() uint16 { + return err.Sequence +} + +func (err ExtensionDisabledError) BadId() uint32 { + return 0 +} + +func (err ExtensionDisabledError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadExtensionDisabled {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][4] = ExtensionDisabledErrorNew +} + +// Error definition ClientNotLocal (5) +// Size: 32 + +const BadClientNotLocal = 5 + +type ClientNotLocalError struct { + Sequence uint16 + NiceName string +} + +// Error read ClientNotLocal +func ClientNotLocalErrorNew(buf []byte) xgb.Error { + v := ClientNotLocalError{} + v.NiceName = "ClientNotLocal" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ClientNotLocalError) ImplementsError() {} + +func (err ClientNotLocalError) SequenceId() uint16 { + return err.Sequence +} + +func (err ClientNotLocalError) BadId() uint32 { + return 0 +} + +func (err ClientNotLocalError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadClientNotLocal {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew +} + +// Error definition ZoomLocked (6) +// Size: 32 + +const BadZoomLocked = 6 + +type ZoomLockedError struct { + Sequence uint16 + NiceName string +} + +// Error read ZoomLocked +func ZoomLockedErrorNew(buf []byte) xgb.Error { + v := ZoomLockedError{} + v.NiceName = "ZoomLocked" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ZoomLockedError) ImplementsError() {} + +func (err ZoomLockedError) SequenceId() uint16 { + return err.Sequence +} + +func (err ZoomLockedError) BadId() uint32 { + return 0 +} + +func (err ZoomLockedError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadZoomLocked {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][6] = ZoomLockedErrorNew +} + +// 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["XFREE86-VIDMODEEXTENSION"] + 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 GetModeLine +// size: 8 +type GetModeLineCookie struct { + *xgb.Cookie +} + +func GetModeLine(c *xgb.Conn, Screen uint16) GetModeLineCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} +} + +func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} +} + +// Request reply for GetModeLine +// size: (52 + xgb.Pad((int(Privsize) * 1))) +type GetModeLineReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint16 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 2 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 + Private []byte // size: xgb.Pad((int(Privsize) * 1)) +} + +// Waits and reads reply data from request GetModeLine +func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getModeLineReply(buf), nil +} + +// Read reply into structure from buffer for GetModeLine +func getModeLineReply(buf []byte) *GetModeLineReply { + v := new(GetModeLineReply) + 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.Dotclock = Dotclock(xgb.Get32(buf[b:])) + b += 4 + + v.Hdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get16(buf[b:]) + b += 2 + + v.Vdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Privsize = xgb.Get32(buf[b:]) + b += 4 + + v.Private = make([]byte, v.Privsize) + copy(v.Private[:v.Privsize], buf[b:]) + b += xgb.Pad(int(v.Privsize)) + + return v +} + +// Write request to wire for GetModeLine +func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request ModModeLine +// size: xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) +type ModModeLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for ModModeLine +func ModModeLine(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ModModeLineCookie{cookie} +} + +func ModModeLineChecked(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ModModeLineCookie{cookie} +} + +func (cook ModModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ModModeLine +func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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:], Screen) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request SwitchMode +// size: 8 +type SwitchModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwitchMode +func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) + return SwitchModeCookie{cookie} +} + +func SwitchModeChecked(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) + return SwitchModeCookie{cookie} +} + +func (cook SwitchModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwitchMode +func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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:], Screen) + b += 2 + + xgb.Put16(buf[b:], Zoom) + b += 2 + + return buf +} + +// Request GetMonitor +// size: 8 +type GetMonitorCookie struct { + *xgb.Cookie +} + +func GetMonitor(c *xgb.Conn, Screen uint16) GetMonitorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} +} + +func GetMonitorUnchecked(c *xgb.Conn, Screen uint16) GetMonitorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} +} + +// Request reply for GetMonitor +// size: (((((32 + xgb.Pad((int(NumHsync) * 4))) + xgb.Pad((int(NumVsync) * 4))) + xgb.Pad((int(VendorLength) * 1))) + xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))) + xgb.Pad((int(ModelLength) * 1))) +type GetMonitorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + VendorLength byte + ModelLength byte + NumHsync byte + NumVsync byte + // padding: 20 bytes + Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) + Vsync []Syncrange // size: xgb.Pad((int(NumVsync) * 4)) + Vendor string // size: xgb.Pad((int(VendorLength) * 1)) + AlignmentPad []byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) + Model string // size: xgb.Pad((int(ModelLength) * 1)) +} + +// Waits and reads reply data from request GetMonitor +func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMonitorReply(buf), nil +} + +// Read reply into structure from buffer for GetMonitor +func getMonitorReply(buf []byte) *GetMonitorReply { + v := new(GetMonitorReply) + 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.VendorLength = buf[b] + b += 1 + + v.ModelLength = buf[b] + b += 1 + + v.NumHsync = buf[b] + b += 1 + + v.NumVsync = buf[b] + b += 1 + + b += 20 // padding + + v.Hsync = make([]Syncrange, v.NumHsync) + for i := 0; i < int(v.NumHsync); i++ { + v.Hsync[i] = Syncrange(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Vsync = make([]Syncrange, v.NumVsync) + for i := 0; i < int(v.NumVsync); i++ { + v.Vsync[i] = Syncrange(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + { + byteString := make([]byte, v.VendorLength) + copy(byteString[:v.VendorLength], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLength)) + } + + v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) + copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) + b += xgb.Pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) + + { + byteString := make([]byte, v.ModelLength) + copy(byteString[:v.ModelLength], buf[b:]) + v.Model = string(byteString) + b += xgb.Pad(int(v.ModelLength)) + } + + return v +} + +// Write request to wire for GetMonitor +func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request LockModeSwitch +// size: 8 +type LockModeSwitchCookie struct { + *xgb.Cookie +} + +// Write request to wire for LockModeSwitch +func LockModeSwitch(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) + return LockModeSwitchCookie{cookie} +} + +func LockModeSwitchChecked(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) + return LockModeSwitchCookie{cookie} +} + +func (cook LockModeSwitchCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for LockModeSwitch +func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Lock) + b += 2 + + return buf +} + +// Request GetAllModeLines +// size: 8 +type GetAllModeLinesCookie struct { + *xgb.Cookie +} + +func GetAllModeLines(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} +} + +func GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} +} + +// Request reply for GetAllModeLines +// size: (32 + xgb.Pad((int(Modecount) * 48))) +type GetAllModeLinesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Modecount uint32 + // padding: 20 bytes + Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) +} + +// Waits and reads reply data from request GetAllModeLines +func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getAllModeLinesReply(buf), nil +} + +// Read reply into structure from buffer for GetAllModeLines +func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { + v := new(GetAllModeLinesReply) + 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.Modecount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Modeinfo = make([]ModeInfo, v.Modecount) + b += ModeInfoReadList(buf[b:], v.Modeinfo) + + return v +} + +// Write request to wire for GetAllModeLines +func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request AddModeLine +// size: xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) +type AddModeLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddModeLine +func AddModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) + return AddModeLineCookie{cookie} +} + +func AddModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) + return AddModeLineCookie{cookie} +} + +func (cook AddModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddModeLine +func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { + size := xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + xgb.Put32(buf[b:], uint32(AfterDotclock)) + b += 4 + + xgb.Put16(buf[b:], AfterHdisplay) + b += 2 + + xgb.Put16(buf[b:], AfterHsyncstart) + b += 2 + + xgb.Put16(buf[b:], AfterHsyncend) + b += 2 + + xgb.Put16(buf[b:], AfterHtotal) + b += 2 + + xgb.Put16(buf[b:], AfterHskew) + b += 2 + + xgb.Put16(buf[b:], AfterVdisplay) + b += 2 + + xgb.Put16(buf[b:], AfterVsyncstart) + b += 2 + + xgb.Put16(buf[b:], AfterVsyncend) + b += 2 + + xgb.Put16(buf[b:], AfterVtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], AfterFlags) + b += 4 + + b += 12 // padding + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request DeleteModeLine +// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +type DeleteModeLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteModeLine +func DeleteModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return DeleteModeLineCookie{cookie} +} + +func DeleteModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return DeleteModeLineCookie{cookie} +} + +func (cook DeleteModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteModeLine +func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request ValidateModeLine +// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +type ValidateModeLineCookie struct { + *xgb.Cookie +} + +func ValidateModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ValidateModeLineCookie{cookie} +} + +func ValidateModeLineUnchecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ValidateModeLineCookie{cookie} +} + +// Request reply for ValidateModeLine +// size: 32 +type ValidateModeLineReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status uint32 + // padding: 20 bytes +} + +// Waits and reads reply data from request ValidateModeLine +func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return validateModeLineReply(buf), nil +} + +// Read reply into structure from buffer for ValidateModeLine +func validateModeLineReply(buf []byte) *ValidateModeLineReply { + v := new(ValidateModeLineReply) + 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.Status = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for ValidateModeLine +func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request SwitchToMode +// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +type SwitchToModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwitchToMode +func SwitchToMode(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return SwitchToModeCookie{cookie} +} + +func SwitchToModeChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return SwitchToModeCookie{cookie} +} + +func (cook SwitchToModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwitchToMode +func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request GetViewPort +// size: 8 +type GetViewPortCookie struct { + *xgb.Cookie +} + +func GetViewPort(c *xgb.Conn, Screen uint16) GetViewPortCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getViewPortRequest(c, Screen), cookie) + return GetViewPortCookie{cookie} +} + +func GetViewPortUnchecked(c *xgb.Conn, Screen uint16) GetViewPortCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getViewPortRequest(c, Screen), cookie) + return GetViewPortCookie{cookie} +} + +// Request reply for GetViewPort +// size: 32 +type GetViewPortReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + X uint32 + Y uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request GetViewPort +func (cook GetViewPortCookie) Reply() (*GetViewPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getViewPortReply(buf), nil +} + +// Read reply into structure from buffer for GetViewPort +func getViewPortReply(buf []byte) *GetViewPortReply { + v := new(GetViewPortReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = xgb.Get32(buf[b:]) + b += 4 + + v.Y = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for GetViewPort +func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request SetViewPort +// size: 16 +type SetViewPortCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetViewPort +func SetViewPort(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} +} + +func SetViewPortChecked(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} +} + +func (cook SetViewPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetViewPort +func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], X) + b += 4 + + xgb.Put32(buf[b:], Y) + b += 4 + + return buf +} + +// Request GetDotClocks +// size: 8 +type GetDotClocksCookie struct { + *xgb.Cookie +} + +func GetDotClocks(c *xgb.Conn, Screen uint16) GetDotClocksCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} +} + +func GetDotClocksUnchecked(c *xgb.Conn, Screen uint16) GetDotClocksCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} +} + +// Request reply for GetDotClocks +// size: (32 + xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4))) +type GetDotClocksReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Flags uint32 + Clocks uint32 + Maxclocks uint32 + // padding: 12 bytes + Clock []uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) +} + +// Waits and reads reply data from request GetDotClocks +func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDotClocksReply(buf), nil +} + +// Read reply into structure from buffer for GetDotClocks +func getDotClocksReply(buf []byte) *GetDotClocksReply { + v := new(GetDotClocksReply) + 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.Flags = xgb.Get32(buf[b:]) + b += 4 + + v.Clocks = xgb.Get32(buf[b:]) + b += 4 + + v.Maxclocks = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Clock = make([]uint32, ((1 - (int(v.Flags) & 1)) * int(v.Clocks))) + for i := 0; i < int(((1 - (int(v.Flags) & 1)) * int(v.Clocks))); i++ { + v.Clock[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDotClocks +func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request SetClientVersion +// size: 8 +type SetClientVersionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClientVersion +func SetClientVersion(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) + return SetClientVersionCookie{cookie} +} + +func SetClientVersionChecked(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) + return SetClientVersionCookie{cookie} +} + +func (cook SetClientVersionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientVersion +func setClientVersionRequest(c *xgb.Conn, Major uint16, Minor uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Major) + b += 2 + + xgb.Put16(buf[b:], Minor) + b += 2 + + return buf +} + +// Request SetGamma +// size: 32 +type SetGammaCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetGamma +func SetGamma(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) + return SetGammaCookie{cookie} +} + +func SetGammaChecked(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) + return SetGammaCookie{cookie} +} + +func (cook SetGammaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGamma +func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Red) + b += 4 + + xgb.Put32(buf[b:], Green) + b += 4 + + xgb.Put32(buf[b:], Blue) + b += 4 + + b += 12 // padding + + return buf +} + +// Request GetGamma +// size: 32 +type GetGammaCookie struct { + *xgb.Cookie +} + +func GetGamma(c *xgb.Conn, Screen uint16) GetGammaCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{cookie} +} + +func GetGammaUnchecked(c *xgb.Conn, Screen uint16) GetGammaCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{cookie} +} + +// Request reply for GetGamma +// size: 32 +type GetGammaReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Red uint32 + Green uint32 + Blue uint32 + // padding: 12 bytes +} + +// Waits and reads reply data from request GetGamma +func (cook GetGammaCookie) Reply() (*GetGammaReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaReply(buf), nil +} + +// Read reply into structure from buffer for GetGamma +func getGammaReply(buf []byte) *GetGammaReply { + v := new(GetGammaReply) + 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.Red = xgb.Get32(buf[b:]) + b += 4 + + v.Green = xgb.Get32(buf[b:]) + b += 4 + + v.Blue = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + return v +} + +// Write request to wire for GetGamma +func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 26 // padding + + return buf +} + +// Request GetGammaRamp +// size: 8 +type GetGammaRampCookie struct { + *xgb.Cookie +} + +func GetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} +} + +func GetGammaRampUnchecked(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} +} + +// Request reply for GetGammaRamp +// size: (((32 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) +type GetGammaRampReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) +} + +// Waits and reads reply data from request GetGammaRamp +func (cook GetGammaRampCookie) Reply() (*GetGammaRampReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaRampReply(buf), nil +} + +// Read reply into structure from buffer for GetGammaRamp +func getGammaRampReply(buf []byte) *GetGammaRampReply { + v := new(GetGammaRampReply) + 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.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Red = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Blue[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetGammaRamp +func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Size) + b += 2 + + return buf +} + +// Request SetGammaRamp +// size: xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) +type SetGammaRampCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetGammaRamp +func SetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} +} + +func SetGammaRampChecked(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} +} + +func (cook SetGammaRampCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGammaRamp +func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { + size := xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Size) + b += 2 + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Red[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Green[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Blue[i]) + b += 2 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetGammaRampSize +// size: 8 +type GetGammaRampSizeCookie struct { + *xgb.Cookie +} + +func GetGammaRampSize(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} +} + +func GetGammaRampSizeUnchecked(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} +} + +// Request reply for GetGammaRampSize +// size: 32 +type GetGammaRampSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes +} + +// Waits and reads reply data from request GetGammaRampSize +func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaRampSizeReply(buf), nil +} + +// Read reply into structure from buffer for GetGammaRampSize +func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { + v := new(GetGammaRampSizeReply) + 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.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetGammaRampSize +func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request GetPermissions +// size: 8 +type GetPermissionsCookie struct { + *xgb.Cookie +} + +func GetPermissions(c *xgb.Conn, Screen uint16) GetPermissionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPermissionsRequest(c, Screen), cookie) + return GetPermissionsCookie{cookie} +} + +func GetPermissionsUnchecked(c *xgb.Conn, Screen uint16) GetPermissionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPermissionsRequest(c, Screen), cookie) + return GetPermissionsCookie{cookie} +} + +// Request reply for GetPermissions +// size: 32 +type GetPermissionsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Permissions uint32 + // padding: 20 bytes +} + +// Waits and reads reply data from request GetPermissions +func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPermissionsReply(buf), nil +} + +// Read reply into structure from buffer for GetPermissions +func getPermissionsReply(buf []byte) *GetPermissionsReply { + v := new(GetPermissionsReply) + 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.Permissions = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for GetPermissions +func getPermissionsRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go new file mode 100644 index 0000000..7115e02 --- /dev/null +++ b/nexgb/xfixes/xfixes.go @@ -0,0 +1,2155 @@ +package xfixes + +/* + This file was generated by xfixes.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/render" + "github.com/BurntSushi/xgb/shape" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XFIXES extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "XFIXES").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFIXES could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFIXES"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFIXES"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFIXES"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +const ( + SaveSetModeInsert = 0 + SaveSetModeDelete = 1 +) + +const ( + SaveSetTargetNearest = 0 + SaveSetTargetRoot = 1 +) + +const ( + SaveSetMappingMap = 0 + SaveSetMappingUnmap = 1 +) + +const ( + SelectionEventSetSelectionOwner = 0 + SelectionEventSelectionWindowDestroy = 1 + SelectionEventSelectionClientClose = 2 +) + +const ( + SelectionEventMaskSetSelectionOwner = 1 + SelectionEventMaskSelectionWindowDestroy = 2 + SelectionEventMaskSelectionClientClose = 4 +) + +const ( + CursorNotifyDisplayCursor = 0 +) + +const ( + CursorNotifyMaskDisplayCursor = 1 +) + +const ( + RegionNone = 0 +) + +type Region uint32 + +func NewRegionId(c *xgb.Conn) (Region, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Region(id), nil +} + +// Event definition SelectionNotify (0) +// Size: 32 + +const SelectionNotify = 0 + +type SelectionNotifyEvent struct { + Sequence uint16 + Subtype byte + Window xproto.Window + Owner xproto.Window + Selection xproto.Atom + Timestamp xproto.Timestamp + SelectionTimestamp xproto.Timestamp + // padding: 8 bytes +} + +// Event read SelectionNotify +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} + b := 1 // don't read event number + + v.Subtype = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Owner = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.SelectionTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + return v +} + +// Event write SelectionNotify +func (v SelectionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Subtype + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.SelectionTimestamp)) + b += 4 + + b += 8 // padding + + return buf +} + +func (v SelectionNotifyEvent) ImplementsEvent() {} + +func (v SelectionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("SelectionTimestamp: %d", v.SelectionTimestamp)) + return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew +} + +// Event definition CursorNotify (1) +// Size: 32 + +const CursorNotify = 1 + +type CursorNotifyEvent struct { + Sequence uint16 + Subtype byte + Window xproto.Window + CursorSerial uint32 + Timestamp xproto.Timestamp + Name xproto.Atom + // padding: 12 bytes +} + +// Event read CursorNotify +func CursorNotifyEventNew(buf []byte) xgb.Event { + v := CursorNotifyEvent{} + b := 1 // don't read event number + + v.Subtype = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Name = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + return v +} + +// Event write CursorNotify +func (v CursorNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Subtype + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], v.CursorSerial) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + b += 12 // padding + + return buf +} + +func (v CursorNotifyEvent) ImplementsEvent() {} + +func (v CursorNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CursorNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name)) + return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew +} + +// Error definition BadRegion (0) +// Size: 32 + +const BadBadRegion = 0 + +type BadRegionError struct { + Sequence uint16 + NiceName string +} + +// Error read BadRegion +func BadRegionErrorNew(buf []byte) xgb.Error { + v := BadRegionError{} + v.NiceName = "BadRegion" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadRegionError) ImplementsError() {} + +func (err BadRegionError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadRegionError) BadId() uint32 { + return 0 +} + +func (err BadRegionError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + +// Request ChangeSaveSet +// size: 12 +type ChangeSaveSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeSaveSet +func ChangeSaveSet(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func (cook ChangeSaveSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeSaveSet +func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Mode + b += 1 + + buf[b] = Target + b += 1 + + buf[b] = Map + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SelectSelectionInput +// size: 16 +type SelectSelectionInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectSelectionInput +func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} +} + +func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} +} + +func (cook SelectSelectionInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectSelectionInput +func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + return buf +} + +// Request SelectCursorInput +// size: 12 +type SelectCursorInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectCursorInput +func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} +} + +func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} +} + +func (cook SelectCursorInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectCursorInput +func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + return buf +} + +// Request GetCursorImage +// size: 4 +type GetCursorImageCookie struct { + *xgb.Cookie +} + +func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} +} + +func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} +} + +// Request reply for GetCursorImage +// size: (32 + xgb.Pad(((int(Width) * int(Height)) * 4))) +type GetCursorImageReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + // padding: 8 bytes + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) +} + +// Waits and reads reply data from request GetCursorImage +func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageReply(buf), nil +} + +// Read reply into structure from buffer for GetCursorImage +func getCursorImageReply(buf []byte) *GetCursorImageReply { + v := new(GetCursorImageReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImage +func getCursorImageRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreateRegion +// size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +type CreateRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegion +func CreateRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) + return CreateRegionCookie{cookie} +} + +func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) + return CreateRegionCookie{cookie} +} + +func (cook CreateRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegion +func createRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request CreateRegionFromBitmap +// size: 12 +type CreateRegionFromBitmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromBitmap +func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) + return CreateRegionFromBitmapCookie{cookie} +} + +func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) + return CreateRegionFromBitmapCookie{cookie} +} + +func (cook CreateRegionFromBitmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromBitmap +func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Bitmap)) + b += 4 + + return buf +} + +// Request CreateRegionFromWindow +// size: 16 +type CreateRegionFromWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromWindow +func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +func (cook CreateRegionFromWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromWindow +func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = byte(Kind) + b += 1 + + b += 3 // padding + + return buf +} + +// Request CreateRegionFromGC +// size: 12 +type CreateRegionFromGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromGC +func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) + return CreateRegionFromGCCookie{cookie} +} + +func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) + return CreateRegionFromGCCookie{cookie} +} + +func (cook CreateRegionFromGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromGC +func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + return buf +} + +// Request CreateRegionFromPicture +// size: 12 +type CreateRegionFromPictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromPicture +func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) + return CreateRegionFromPictureCookie{cookie} +} + +func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) + return CreateRegionFromPictureCookie{cookie} +} + +func (cook CreateRegionFromPictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromPicture +func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + return buf +} + +// Request DestroyRegion +// size: 8 +type DestroyRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyRegion +func DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyRegionRequest(c, Region), cookie) + return DestroyRegionCookie{cookie} +} + +func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyRegionRequest(c, Region), cookie) + return DestroyRegionCookie{cookie} +} + +func (cook DestroyRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyRegion +func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// Request SetRegion +// size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +type SetRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetRegion +func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} + +func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} + +func (cook SetRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetRegion +func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request CopyRegion +// size: 12 +type CopyRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyRegion +func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} +} + +func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} +} + +func (cook CopyRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyRegion +func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request UnionRegion +// size: 16 +type UnionRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnionRegion +func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} +} + +func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} +} + +func (cook UnionRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnionRegion +func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request IntersectRegion +// size: 16 +type IntersectRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for IntersectRegion +func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} +} + +func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} +} + +func (cook IntersectRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for IntersectRegion +func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request SubtractRegion +// size: 16 +type SubtractRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SubtractRegion +func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} +} + +func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} +} + +func (cook SubtractRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SubtractRegion +func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request InvertRegion +// size: 20 +type InvertRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for InvertRegion +func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} +} + +func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} +} + +func (cook InvertRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InvertRegion +func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + { + structBytes := Bounds.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request TranslateRegion +// size: 12 +type TranslateRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for TranslateRegion +func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} +} + +func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} +} + +func (cook TranslateRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TranslateRegion +func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(Dx)) + b += 2 + + xgb.Put16(buf[b:], uint16(Dy)) + b += 2 + + return buf +} + +// Request RegionExtents +// size: 12 +type RegionExtentsCookie struct { + *xgb.Cookie +} + +// Write request to wire for RegionExtents +func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} +} + +func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} +} + +func (cook RegionExtentsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RegionExtents +func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request FetchRegion +// size: 8 +type FetchRegionCookie struct { + *xgb.Cookie +} + +func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} +} + +func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} +} + +// Request reply for FetchRegion +// size: (32 + xgb.Pad(((int(Length) / 2) * 8))) +type FetchRegionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Extents xproto.Rectangle + // padding: 16 bytes + Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) +} + +// Waits and reads reply data from request FetchRegion +func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return fetchRegionReply(buf), nil +} + +// Read reply into structure from buffer for FetchRegion +func fetchRegionReply(buf []byte) *FetchRegionReply { + v := new(FetchRegionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Extents = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Extents) + + b += 16 // padding + + v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for FetchRegion +func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// Request SetGCClipRegion +// size: 16 +type SetGCClipRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetGCClipRegion +func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} +} + +func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} +} + +func (cook SetGCClipRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGCClipRegion +func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// Request SetWindowShapeRegion +// size: 20 +type SetWindowShapeRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetWindowShapeRegion +func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} +} + +func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} +} + +func (cook SetWindowShapeRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowShapeRegion +func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Dest)) + b += 4 + + buf[b] = byte(DestKind) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// Request SetPictureClipRegion +// size: 16 +type SetPictureClipRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureClipRegion +func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} +} + +func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} +} + +func (cook SetPictureClipRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureClipRegion +func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// Request SetCursorName +// size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +type SetCursorNameCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCursorName +func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) + return SetCursorNameCookie{cookie} +} + +func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) + return SetCursorNameCookie{cookie} +} + +func (cook SetCursorNameCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCursorName +func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) + + return buf +} + +// Request GetCursorName +// size: 8 +type GetCursorNameCookie struct { + *xgb.Cookie +} + +func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} +} + +func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} +} + +// Request reply for GetCursorName +// size: (32 + xgb.Pad((int(Nbytes) * 1))) +type GetCursorNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Atom xproto.Atom + Nbytes uint16 + // padding: 18 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) +} + +// Waits and reads reply data from request GetCursorName +func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorNameReply(buf), nil +} + +// Read reply into structure from buffer for GetCursorName +func getCursorNameReply(buf []byte) *GetCursorNameReply { + v := new(GetCursorNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + return v +} + +// Write request to wire for GetCursorName +func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + return buf +} + +// Request GetCursorImageAndName +// size: 4 +type GetCursorImageAndNameCookie struct { + *xgb.Cookie +} + +func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} +} + +func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} +} + +// Request reply for GetCursorImageAndName +// size: ((32 + xgb.Pad((int(Nbytes) * 1))) + xgb.Pad(((int(Width) * int(Height)) * 4))) +type GetCursorImageAndNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + CursorAtom xproto.Atom + Nbytes uint16 + // padding: 2 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) +} + +// Waits and reads reply data from request GetCursorImageAndName +func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageAndNameReply(buf), nil +} + +// Read reply into structure from buffer for GetCursorImageAndName +func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { + v := new(GetCursorImageAndNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImageAndName +func getCursorImageAndNameRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangeCursor +// size: 12 +type ChangeCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeCursor +func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} +} + +func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} +} + +func (cook ChangeCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCursor +func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request ChangeCursorByName +// size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +type ChangeCursorByNameCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeCursorByName +func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} +} + +func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} +} + +func (cook ChangeCursorByNameCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCursorByName +func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) + + return buf +} + +// Request ExpandRegion +// size: 20 +type ExpandRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for ExpandRegion +func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} +} + +func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} +} + +func (cook ExpandRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ExpandRegion +func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + xgb.Put16(buf[b:], Left) + b += 2 + + xgb.Put16(buf[b:], Right) + b += 2 + + xgb.Put16(buf[b:], Top) + b += 2 + + xgb.Put16(buf[b:], Bottom) + b += 2 + + return buf +} + +// Request HideCursor +// size: 8 +type HideCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for HideCursor +func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} +} + +func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} +} + +func (cook HideCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for HideCursor +func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ShowCursor +// size: 8 +type ShowCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for ShowCursor +func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} +} + +func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} +} + +func (cook ShowCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ShowCursor +func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 6a71187..75af854 100644 --- a/nexgb/xgb.go +++ b/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) diff --git a/nexgb/xgb_help.go b/nexgb/xgb_help.go index 6c3b40a..36fe98b 100644 --- a/nexgb/xgb_help.go +++ b/nexgb/xgb_help.go @@ -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++ { diff --git a/nexgb/xgb_test.go b/nexgb/xgb_test.go deleted file mode 100644 index d0e840a..0000000 --- a/nexgb/xgb_test.go +++ /dev/null @@ -1,376 +0,0 @@ -package xgb - -/* - Tests for XGB. - - These tests only test the core X protocol at the moment. It isn't even - close to complete coverage (and probably never will be), but it does test - a number of different corners: requests with no replies, requests without - replies, checked (i.e., synchronous) errors, unchecked (i.e., asynchronous) - errors, and sequence number wrapping. - - There are also a couple of benchmarks that show the difference between - correctly issuing lots of requests and gathering replies and - incorrectly doing the same. (This particular difference is one of the - claimed advantages of the XCB, and therefore XGB, family. -*/ - -import ( - "fmt" - "log" - "math/rand" - "testing" - "time" -) - -// The X connection used throughout testing. -var X *Conn - -// init initializes the X connection, seeds the RNG and starts waiting -// for events. -func init() { - var err error - - X, err = NewConn() - if err != nil { - log.Fatal(err) - } - - rand.Seed(time.Now().UnixNano()) - - go grabEvents() -} - -/******************************************************************************/ -// Tests -/******************************************************************************/ - -// 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 - if err == nil { - t.Fatalf("MapWindow: A MapWindow request that should return an " + - "error has returned a nil error.") - } - verifyMapWindowError(t, err) -} - -// 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 - - evOrErr := waitForEvent(t, 5) - if evOrErr.ev != nil { - t.Fatalf("After issuing an erroneous MapWindow request, we have "+ - "received an event rather than an error: %s", evOrErr.ev) - } - verifyMapWindowError(t, evOrErr.err) -} - -// TestCookieBuffer issues (2^16) + n requets *without* replies to guarantee -// that the sequence number wraps and that the cookie buffer will have to -// flush itself (since there are no replies coming in to flush it). -// And just like TestSequenceWrap, we issue another request with a reply -// at the end to make sure XGB is still working properly. -func TestCookieBuffer(t *testing.T) { - n := (1 << 16) + 10 - for i := 0; i < n; i++ { - X.NoOperation() - } - TestProperty(t) -} - -// TestSequenceWrap issues (2^16) + n requests w/ replies to guarantee that the -// sequence number (which is a 16 bit integer) will wrap. It then issues one -// final request to ensure things still work properly. -func TestSequenceWrap(t *testing.T) { - n := (1 << 16) + 10 - for i := 0; i < n; i++ { - _, err := X.InternAtom(false, 5, "RANDO").Reply() - if err != nil { - t.Fatalf("InternAtom: %s", err) - } - } - TestProperty(t) -} - -// TestProperty tests whether a random value can be set and read. -func TestProperty(t *testing.T) { - propName := randString(20) // whatevs - writeVal := randString(20) - readVal, err := changeAndGetProp(propName, writeVal) - if err != nil { - t.Error(err) - } - - if readVal != writeVal { - t.Errorf("The value written, '%s', is not the same as the "+ - "value read '%s'.", writeVal, readVal) - } -} - -// TestWindowEvents creates a window, maps it, listens for configure notify -// events, issues a configure request, and checks for the appropriate -// configure notify event. -// This probably violates the notion of "test one thing and test it well," -// but testing X stuff is unique since it involves so much state. -// Each request is checked to make sure there are no errors returned. If there -// is an error, the test is failed. -// You may see a window appear quickly and then disappear. Do not be alarmed :P -// It's possible that this test will yield a false negative because we cannot -// control our environment. That is, the window manager could override the -// placement set. However, we set override redirect on the window, so the -// window manager *shouldn't* touch our window if it is well-behaved. -func TestWindowEvents(t *testing.T) { - // The geometry to set the window. - gx, gy, gw, gh := 200, 400, 1000, 300 - - wid, err := X.NewWindowId() - if err != nil { - t.Fatalf("NewId: %s", err) - } - - screen := X.DefaultScreen() // alias - err = X.CreateWindowChecked(screen.RootDepth, wid, screen.Root, - 0, 0, 500, 500, 0, - WindowClassInputOutput, screen.RootVisual, - CwBackPixel|CwOverrideRedirect, []uint32{0xffffffff, 1}).Check() - if err != nil { - t.Fatalf("CreateWindow: %s", err) - } - - err = X.MapWindowChecked(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, - CwEventMask, []uint32{EventMaskStructureNotify}).Check() - if err != nil { - t.Fatalf("ChangeWindowAttributes: %s", err) - } - - err = X.ConfigureWindowChecked(wid, - ConfigWindowX|ConfigWindowY| - ConfigWindowWidth|ConfigWindowHeight, - []uint32{uint32(gx), 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 + 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) - switch event := evOrErr.ev.(type) { - case ConfigureNotifyEvent: - if event.X != int16(gx) { - t.Fatalf("x was set to %d but ConfigureNotify reports %d", - gx, event.X) - } - if event.Y != int16(gy) { - t.Fatalf("y was set to %d but ConfigureNotify reports %d", - gy, event.Y) - } - if event.Width != uint16(gw) { - t.Fatalf("width was set to %d but ConfigureNotify reports %d", - gw, event.Width) - } - if event.Height != uint16(gh) { - t.Fatalf("height was set to %d but ConfigureNotify reports %d", - gh, event.Height) - } - default: - t.Fatalf("Expected a ConfigureNotifyEvent but got %T instead.", event) - } - - // Okay, clean up! - err = X.ChangeWindowAttributesChecked(wid, - CwEventMask, []uint32{0}).Check() - if err != nil { - t.Fatalf("ChangeWindowAttributes: %s", err) - } - - err = X.DestroyWindowChecked(wid).Check() - if err != nil { - t.Fatalf("DestroyWindow: %s", err) - } -} - -/******************************************************************************/ -// Benchmarks -/******************************************************************************/ - -// BenchmarkInternAtomsGood shows how many requests with replies -// *should* be sent and gathered from the server. Namely, send as many -// requests as you can at once, then go back and gather up all the replies. -// More importantly, this approach can exploit parallelism when -// GOMAXPROCS > 1. -// Run with `go test -run 'nomatch' -bench '.*' -cpu 1,2,6` if you have -// multiple cores to see the improvement that parallelism brings. -func BenchmarkInternAtomsGood(b *testing.B) { - b.StopTimer() - names := seqNames(b.N) - - 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]) - } - for _, cookie := range cookies { - cookie.Reply() - } -} - -// BenchmarkInternAtomsBad shows how *not* to issue a lot of requests with -// replies. Namely, each subsequent request isn't issued *until* the last -// reply is made. This implies a round trip to the X server for every -// iteration. -func BenchmarkInternAtomsPoor(b *testing.B) { - b.StopTimer() - names := seqNames(b.N) - - b.StartTimer() - for i := 0; i < b.N; i++ { - X.InternAtom(false, uint16(len(names[i])), names[i]).Reply() - } -} - -/******************************************************************************/ -// Helper functions -/******************************************************************************/ - -// changeAndGetProp sets property 'prop' with value 'val'. -// It then gets the value of that property and returns it. -// (It's used to check that the 'val' going in is the same 'val' going out.) -// 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() - if err != nil { - return "", fmt.Errorf("InternAtom: %s", err) - } - - typName := "UTF8_STRING" - typAtom, err := X.InternAtom(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() - if err != nil { - return "", fmt.Errorf("ChangeProperty: %s", err) - } - - reply, err := X.GetProperty(false, X.DefaultScreen().Root, propAtom.Atom, - GetPropertyTypeAny, 0, (1<<32)-1).Reply() - if err != nil { - return "", fmt.Errorf("GetProperty: %s", err) - } - if reply.Format != 8 { - return "", fmt.Errorf("Property reply format is %d but it should be 8.", - reply.Format) - } - - return string(reply.Value), nil -} - -// verifyMapWindowError takes an error that is returned with an invalid -// MapWindow request with a window Id of 0 and makes sure the error is the -// right type and contains the correct values. -func verifyMapWindowError(t *testing.T, err error) { - switch e := err.(type) { - case WindowError: - if e.BadValue != 0 { - t.Fatalf("WindowError should report a bad value of 0 but "+ - "it reports %d instead.", e.BadValue) - } - if e.MajorOpcode != 8 { - t.Fatalf("WindowError should report a major opcode of 8 "+ - "(which is a MapWindow request), but it reports %d instead.", - e.MajorOpcode) - } - default: - t.Fatalf("Expected a WindowError but got %T instead.", e) - } -} - -// randString generates a random string of length n. -func randString(n int) string { - byts := make([]byte, n) - for i := 0; i < n; i++ { - rando := rand.Intn(53) - switch { - case rando <= 25: - byts[i] = byte(65 + rando) - case rando <= 51: - byts[i] = byte(97 + rando - 26) - default: - byts[i] = ' ' - } - } - return string(byts) -} - -// seqNames creates a slice of NAME0, NAME1, ..., NAMEN. -func seqNames(n int) []string { - names := make([]string, n) - for i := range names { - names[i] = fmt.Sprintf("NAME%d", i) - } - return names -} - -// evErr represents a value that is either an event or an error. -type evErr struct { - ev Event - err Error -} - -// channel used to pass evErrs. -var evOrErrChan = make(chan evErr, 0) - -// grabEvents is a goroutine that reads events off the wire. -// We used this instead of WaitForEvent directly in our tests so that -// we can timeout and fail a test. -func grabEvents() { - for { - ev, err := X.WaitForEvent() - evOrErrChan <- evErr{ev, err} - } -} - -// waitForEvent asks the evOrErrChan channel for an event. -// If it doesn't get an event in 'n' seconds, the current test is failed. -func waitForEvent(t *testing.T, n int) evErr { - var evOrErr evErr - - select { - case evOrErr = <-evOrErrChan: - case <-time.After(time.Second * 5): - t.Fatalf("After waiting 5 seconds for an event or an error, " + - "we have timed out.") - } - - return evOrErr -} diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index a7a1d1d..67699cf 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -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) + // 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("") + 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("") } diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index 0966b58..2047b5f 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -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 { diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 7c83f1a..78475f8 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -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}, diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index 2b2c191..6c680e8 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -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 diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index f4577ef..b7721be 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -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) } diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index f55e26f..d7ef109 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -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) } diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index b01519b..4cf962a 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -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()) diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index a9e624d..200260c 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -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.check()") - c.Putln("}") - c.Putln("") + c.Putln("func (cook %s) Check() error {", r.CookieName()) + c.Putln("return cook.Cookie.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, ", ") } diff --git a/nexgb/xgbgen/go_single_field.go b/nexgb/xgbgen/go_single_field.go index 433ebe3..3e3fa53 100644 --- a/nexgb/xgbgen/go_single_field.go +++ b/nexgb/xgbgen/go_single_field.go @@ -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) diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 9884194..7f33b21 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -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("}") diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 73e85f7..91300a2 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -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("}") diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index 83dde14..d56663d 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -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 { diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index 4daa4ac..637266b 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -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 { diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 44d615d..0123669 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -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) } diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go new file mode 100644 index 0000000..eb7cd9a --- /dev/null +++ b/nexgb/xinerama/xinerama.go @@ -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 +} diff --git a/nexgb/xinput/xinput.go b/nexgb/xinput/xinput.go new file mode 100644 index 0000000..40635f3 --- /dev/null +++ b/nexgb/xinput/xinput.go @@ -0,0 +1,7219 @@ +package xinput + +/* + This file was generated by xinput.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 XInputExtension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 15, "XInputExtension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XInputExtension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XInputExtension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XInputExtension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XInputExtension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XInputExtension"] = 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 ( + ValuatorModeRelative = 0 + ValuatorModeAbsolute = 1 +) + +const ( + PropagateModeAddToList = 0 + PropagateModeDeleteFromList = 1 +) + +const ( + DeviceUseIsXPointer = 0 + DeviceUseIsXKeyboard = 1 + DeviceUseIsXExtensionDevice = 2 + DeviceUseIsXExtensionKeyboard = 3 + DeviceUseIsXExtensionPointer = 4 +) + +const ( + InputClassKey = 0 + InputClassButton = 1 + InputClassValuator = 2 + InputClassFeedback = 3 + InputClassProximity = 4 + InputClassFocus = 5 + InputClassOther = 6 +) + +const ( + DeviceInputModeAsyncThisDevice = 0 + DeviceInputModeSyncThisDevice = 1 + DeviceInputModeReplayThisDevice = 2 + DeviceInputModeAsyncOtherDevices = 3 + DeviceInputModeAsyncAll = 4 + DeviceInputModeSyncAll = 5 +) + +const ( + FeedbackClassKeyboard = 0 + FeedbackClassPointer = 1 + FeedbackClassString = 2 + FeedbackClassInteger = 3 + FeedbackClassLed = 4 + FeedbackClassBell = 5 +) + +type KeyCode byte + +type EventClass uint32 + +// 'DeviceInfo' struct definition +// Size: 8 +type DeviceInfo struct { + DeviceType xproto.Atom + DeviceId byte + NumClassInfo byte + DeviceUse byte + // padding: 1 bytes +} + +// Struct read DeviceInfo +func DeviceInfoRead(buf []byte, v *DeviceInfo) int { + b := 0 + + v.DeviceType = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.DeviceId = buf[b] + b += 1 + + v.NumClassInfo = buf[b] + b += 1 + + v.DeviceUse = buf[b] + b += 1 + + b += 1 // padding + + return b +} + +// Struct list read DeviceInfo +func DeviceInfoReadList(buf []byte, dest []DeviceInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceInfo{} + b += DeviceInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceInfo +func (v DeviceInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.DeviceType)) + b += 4 + + buf[b] = v.DeviceId + b += 1 + + buf[b] = v.NumClassInfo + b += 1 + + buf[b] = v.DeviceUse + b += 1 + + b += 1 // padding + + return buf +} + +// Write struct list DeviceInfo +func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'InputInfo' struct definition +// Size: 2 +type InputInfo struct { + ClassId byte + Len byte +} + +// Struct read InputInfo +func InputInfoRead(buf []byte, v *InputInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + return b +} + +// Struct list read InputInfo +func InputInfoReadList(buf []byte, dest []InputInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = InputInfo{} + b += InputInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write InputInfo +func (v InputInfo) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + return buf +} + +// Write struct list InputInfo +func InputInfoListBytes(buf []byte, list []InputInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KeyInfo' struct definition +// Size: 8 +type KeyInfo struct { + ClassId byte + Len byte + MinKeycode KeyCode + MaxKeycode KeyCode + NumKeys uint16 + // padding: 2 bytes +} + +// Struct read KeyInfo +func KeyInfoRead(buf []byte, v *KeyInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.MinKeycode = KeyCode(buf[b]) + b += 1 + + v.MaxKeycode = KeyCode(buf[b]) + b += 1 + + v.NumKeys = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// Struct list read KeyInfo +func KeyInfoReadList(buf []byte, dest []KeyInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KeyInfo{} + b += KeyInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KeyInfo +func (v KeyInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + xgb.Put16(buf[b:], v.NumKeys) + b += 2 + + b += 2 // padding + + return buf +} + +// Write struct list KeyInfo +func KeyInfoListBytes(buf []byte, list []KeyInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ButtonInfo' struct definition +// Size: 4 +type ButtonInfo struct { + ClassId byte + Len byte + NumButtons uint16 +} + +// Struct read ButtonInfo +func ButtonInfoRead(buf []byte, v *ButtonInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumButtons = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read ButtonInfo +func ButtonInfoReadList(buf []byte, dest []ButtonInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ButtonInfo{} + b += ButtonInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ButtonInfo +func (v ButtonInfo) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + xgb.Put16(buf[b:], v.NumButtons) + b += 2 + + return buf +} + +// Write struct list ButtonInfo +func ButtonInfoListBytes(buf []byte, list []ButtonInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AxisInfo' struct definition +// Size: 12 +type AxisInfo struct { + Resolution uint32 + Minimum int32 + Maximum int32 +} + +// Struct read AxisInfo +func AxisInfoRead(buf []byte, v *AxisInfo) int { + b := 0 + + v.Resolution = xgb.Get32(buf[b:]) + b += 4 + + v.Minimum = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Maximum = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read AxisInfo +func AxisInfoReadList(buf []byte, dest []AxisInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AxisInfo{} + b += AxisInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AxisInfo +func (v AxisInfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Resolution) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Minimum)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Maximum)) + b += 4 + + return buf +} + +// Write struct list AxisInfo +func AxisInfoListBytes(buf []byte, list []AxisInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ValuatorInfo' struct definition +// Size: (8 + xgb.Pad((int(AxesLen) * 12))) +type ValuatorInfo struct { + ClassId byte + Len byte + AxesLen byte + Mode byte + MotionSize uint32 + Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) +} + +// Struct read ValuatorInfo +func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.AxesLen = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.MotionSize = xgb.Get32(buf[b:]) + b += 4 + + v.Axes = make([]AxisInfo, v.AxesLen) + b += AxisInfoReadList(buf[b:], v.Axes) + + return b +} + +// Struct list read ValuatorInfo +func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorInfo{} + b += ValuatorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ValuatorInfo +func (v ValuatorInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.AxesLen) * 12)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.AxesLen + b += 1 + + buf[b] = v.Mode + b += 1 + + xgb.Put32(buf[b:], v.MotionSize) + b += 4 + + b += AxisInfoListBytes(buf[b:], v.Axes) + + return buf +} + +// Write struct list ValuatorInfo +func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ValuatorInfo +func ValuatorInfoListSize(list []ValuatorInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.AxesLen) * 12))) + } + return size +} + +// 'InputClassInfo' struct definition +// Size: 2 +type InputClassInfo struct { + ClassId byte + EventTypeBase byte +} + +// Struct read InputClassInfo +func InputClassInfoRead(buf []byte, v *InputClassInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.EventTypeBase = buf[b] + b += 1 + + return b +} + +// Struct list read InputClassInfo +func InputClassInfoReadList(buf []byte, dest []InputClassInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = InputClassInfo{} + b += InputClassInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write InputClassInfo +func (v InputClassInfo) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.EventTypeBase + b += 1 + + return buf +} + +// Write struct list InputClassInfo +func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceTimeCoord' struct definition +// Size: 4 +type DeviceTimeCoord struct { + Time xproto.Timestamp +} + +// Struct read DeviceTimeCoord +func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { + b := 0 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read DeviceTimeCoord +func DeviceTimeCoordReadList(buf []byte, dest []DeviceTimeCoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceTimeCoord{} + b += DeviceTimeCoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceTimeCoord +func (v DeviceTimeCoord) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + return buf +} + +// Write struct list DeviceTimeCoord +func DeviceTimeCoordListBytes(buf []byte, list []DeviceTimeCoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'FeedbackState' struct definition +// Size: 4 +type FeedbackState struct { + ClassId byte + Id byte + Len uint16 +} + +// Struct read FeedbackState +func FeedbackStateRead(buf []byte, v *FeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read FeedbackState +func FeedbackStateReadList(buf []byte, dest []FeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = FeedbackState{} + b += FeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write FeedbackState +func (v FeedbackState) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list FeedbackState +func FeedbackStateListBytes(buf []byte, list []FeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KbdFeedbackState' struct definition +// Size: 52 +type KbdFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Pitch uint16 + Duration uint16 + LedMask uint32 + LedValues uint32 + GlobalAutoRepeat bool + Click byte + Percent byte + // padding: 1 bytes + AutoRepeats []byte // size: 32 +} + +// Struct read KbdFeedbackState +func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Pitch = xgb.Get16(buf[b:]) + b += 2 + + v.Duration = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.GlobalAutoRepeat = true + } else { + v.GlobalAutoRepeat = false + } + b += 1 + + v.Click = buf[b] + b += 1 + + v.Percent = buf[b] + b += 1 + + b += 1 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// Struct list read KbdFeedbackState +func KbdFeedbackStateReadList(buf []byte, dest []KbdFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KbdFeedbackState{} + b += KbdFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KbdFeedbackState +func (v KbdFeedbackState) Bytes() []byte { + buf := make([]byte, 52) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put16(buf[b:], v.Pitch) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + if v.GlobalAutoRepeat { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.Click + b += 1 + + buf[b] = v.Percent + b += 1 + + b += 1 // padding + + copy(buf[b:], v.AutoRepeats[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Write struct list KbdFeedbackState +func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size KbdFeedbackState +func KbdFeedbackStateListSize(list []KbdFeedbackState) int { + size := 0 + for _ = range list { + size += 52 + } + return size +} + +// 'PtrFeedbackState' struct definition +// Size: 12 +type PtrFeedbackState struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + AccelNum uint16 + AccelDenom uint16 + Threshold uint16 +} + +// Struct read PtrFeedbackState +func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AccelNum = xgb.Get16(buf[b:]) + b += 2 + + v.AccelDenom = xgb.Get16(buf[b:]) + b += 2 + + v.Threshold = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read PtrFeedbackState +func PtrFeedbackStateReadList(buf []byte, dest []PtrFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = PtrFeedbackState{} + b += PtrFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write PtrFeedbackState +func (v PtrFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], v.AccelNum) + b += 2 + + xgb.Put16(buf[b:], v.AccelDenom) + b += 2 + + xgb.Put16(buf[b:], v.Threshold) + b += 2 + + return buf +} + +// Write struct list PtrFeedbackState +func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'IntegerFeedbackState' struct definition +// Size: 16 +type IntegerFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Resolution uint32 + MinValue int32 + MaxValue int32 +} + +// Struct read IntegerFeedbackState +func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Resolution = xgb.Get32(buf[b:]) + b += 4 + + v.MinValue = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxValue = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read IntegerFeedbackState +func IntegerFeedbackStateReadList(buf []byte, dest []IntegerFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackState{} + b += IntegerFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write IntegerFeedbackState +func (v IntegerFeedbackState) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.Resolution) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinValue)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxValue)) + b += 4 + + return buf +} + +// Write struct list IntegerFeedbackState +func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'StringFeedbackState' struct definition +// Size: (8 + xgb.Pad((int(NumKeysyms) * 4))) +type StringFeedbackState struct { + ClassId byte + Id byte + Len uint16 + MaxSymbols uint16 + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} + +// Struct read StringFeedbackState +func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MaxSymbols = xgb.Get16(buf[b:]) + b += 2 + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read StringFeedbackState +func StringFeedbackStateReadList(buf []byte, dest []StringFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = StringFeedbackState{} + b += StringFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write StringFeedbackState +func (v StringFeedbackState) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put16(buf[b:], v.MaxSymbols) + b += 2 + + xgb.Put16(buf[b:], v.NumKeysyms) + b += 2 + + for i := 0; i < int(v.NumKeysyms); i++ { + xgb.Put32(buf[b:], uint32(v.Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list StringFeedbackState +func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size StringFeedbackState +func StringFeedbackStateListSize(list []StringFeedbackState) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) + } + return size +} + +// 'BellFeedbackState' struct definition +// Size: 12 +type BellFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Percent byte + // padding: 3 bytes + Pitch uint16 + Duration uint16 +} + +// Struct read BellFeedbackState +func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Percent = buf[b] + b += 1 + + b += 3 // padding + + v.Pitch = xgb.Get16(buf[b:]) + b += 2 + + v.Duration = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read BellFeedbackState +func BellFeedbackStateReadList(buf []byte, dest []BellFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = BellFeedbackState{} + b += BellFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write BellFeedbackState +func (v BellFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Percent + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], v.Pitch) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 + + return buf +} + +// Write struct list BellFeedbackState +func BellFeedbackStateListBytes(buf []byte, list []BellFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'LedFeedbackState' struct definition +// Size: 12 +type LedFeedbackState struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 +} + +// Struct read LedFeedbackState +func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read LedFeedbackState +func LedFeedbackStateReadList(buf []byte, dest []LedFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = LedFeedbackState{} + b += LedFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write LedFeedbackState +func (v LedFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// Write struct list LedFeedbackState +func LedFeedbackStateListBytes(buf []byte, list []LedFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'FeedbackCtl' struct definition +// Size: 4 +type FeedbackCtl struct { + ClassId byte + Id byte + Len uint16 +} + +// Struct read FeedbackCtl +func FeedbackCtlRead(buf []byte, v *FeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read FeedbackCtl +func FeedbackCtlReadList(buf []byte, dest []FeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = FeedbackCtl{} + b += FeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write FeedbackCtl +func (v FeedbackCtl) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list FeedbackCtl +func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KbdFeedbackCtl' struct definition +// Size: 20 +type KbdFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + Key KeyCode + AutoRepeatMode byte + KeyClickPercent int8 + BellPercent int8 + BellPitch int16 + BellDuration int16 + LedMask uint32 + LedValues uint32 +} + +// Struct read KbdFeedbackCtl +func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Key = KeyCode(buf[b]) + b += 1 + + v.AutoRepeatMode = buf[b] + b += 1 + + v.KeyClickPercent = int8(buf[b]) + b += 1 + + v.BellPercent = int8(buf[b]) + b += 1 + + v.BellPitch = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BellDuration = int16(xgb.Get16(buf[b:])) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read KbdFeedbackCtl +func KbdFeedbackCtlReadList(buf []byte, dest []KbdFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KbdFeedbackCtl{} + b += KbdFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KbdFeedbackCtl +func (v KbdFeedbackCtl) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = byte(v.Key) + b += 1 + + buf[b] = v.AutoRepeatMode + b += 1 + + buf[b] = byte(v.KeyClickPercent) + b += 1 + + buf[b] = byte(v.BellPercent) + b += 1 + + xgb.Put16(buf[b:], uint16(v.BellPitch)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.BellDuration)) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// Write struct list KbdFeedbackCtl +func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'PtrFeedbackCtl' struct definition +// Size: 12 +type PtrFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + Num int16 + Denom int16 + Threshold int16 +} + +// Struct read PtrFeedbackCtl +func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Num = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Denom = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Threshold = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read PtrFeedbackCtl +func PtrFeedbackCtlReadList(buf []byte, dest []PtrFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = PtrFeedbackCtl{} + b += PtrFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write PtrFeedbackCtl +func (v PtrFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], uint16(v.Num)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Denom)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Threshold)) + b += 2 + + return buf +} + +// Write struct list PtrFeedbackCtl +func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'IntegerFeedbackCtl' struct definition +// Size: 8 +type IntegerFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + IntToDisplay int32 +} + +// Struct read IntegerFeedbackCtl +func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.IntToDisplay = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read IntegerFeedbackCtl +func IntegerFeedbackCtlReadList(buf []byte, dest []IntegerFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackCtl{} + b += IntegerFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write IntegerFeedbackCtl +func (v IntegerFeedbackCtl) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.IntToDisplay)) + b += 4 + + return buf +} + +// Write struct list IntegerFeedbackCtl +func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'StringFeedbackCtl' struct definition +// Size: (8 + xgb.Pad((int(NumKeysyms) * 4))) +type StringFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} + +// Struct read StringFeedbackCtl +func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read StringFeedbackCtl +func StringFeedbackCtlReadList(buf []byte, dest []StringFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = StringFeedbackCtl{} + b += StringFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write StringFeedbackCtl +func (v StringFeedbackCtl) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], v.NumKeysyms) + b += 2 + + for i := 0; i < int(v.NumKeysyms); i++ { + xgb.Put32(buf[b:], uint32(v.Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list StringFeedbackCtl +func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size StringFeedbackCtl +func StringFeedbackCtlListSize(list []StringFeedbackCtl) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) + } + return size +} + +// 'BellFeedbackCtl' struct definition +// Size: 12 +type BellFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + Percent int8 + // padding: 3 bytes + Pitch int16 + Duration int16 +} + +// Struct read BellFeedbackCtl +func BellFeedbackCtlRead(buf []byte, v *BellFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Percent = int8(buf[b]) + b += 1 + + b += 3 // padding + + v.Pitch = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Duration = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read BellFeedbackCtl +func BellFeedbackCtlReadList(buf []byte, dest []BellFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = BellFeedbackCtl{} + b += BellFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write BellFeedbackCtl +func (v BellFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = byte(v.Percent) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(v.Pitch)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Duration)) + b += 2 + + return buf +} + +// Write struct list BellFeedbackCtl +func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'LedFeedbackCtl' struct definition +// Size: 12 +type LedFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 +} + +// Struct read LedFeedbackCtl +func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read LedFeedbackCtl +func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = LedFeedbackCtl{} + b += LedFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write LedFeedbackCtl +func (v LedFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// Write struct list LedFeedbackCtl +func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'InputState' struct definition +// Size: 3 +type InputState struct { + ClassId byte + Len byte + NumItems byte +} + +// Struct read InputState +func InputStateRead(buf []byte, v *InputState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumItems = buf[b] + b += 1 + + return b +} + +// Struct list read InputState +func InputStateReadList(buf []byte, dest []InputState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = InputState{} + b += InputStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write InputState +func (v InputState) Bytes() []byte { + buf := make([]byte, 3) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumItems + b += 1 + + return buf +} + +// Write struct list InputState +func InputStateListBytes(buf []byte, list []InputState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KeyState' struct definition +// Size: 36 +type KeyState struct { + ClassId byte + Len byte + NumKeys byte + // padding: 1 bytes + Keys []byte // size: 32 +} + +// Struct read KeyState +func KeyStateRead(buf []byte, v *KeyState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumKeys = buf[b] + b += 1 + + b += 1 // padding + + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// Struct list read KeyState +func KeyStateReadList(buf []byte, dest []KeyState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KeyState{} + b += KeyStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KeyState +func (v KeyState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumKeys + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Keys[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Write struct list KeyState +func KeyStateListBytes(buf []byte, list []KeyState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size KeyState +func KeyStateListSize(list []KeyState) int { + size := 0 + for _ = range list { + size += 36 + } + return size +} + +// 'ButtonState' struct definition +// Size: 36 +type ButtonState struct { + ClassId byte + Len byte + NumButtons byte + // padding: 1 bytes + Buttons []byte // size: 32 +} + +// Struct read ButtonState +func ButtonStateRead(buf []byte, v *ButtonState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumButtons = buf[b] + b += 1 + + b += 1 // padding + + v.Buttons = make([]byte, 32) + copy(v.Buttons[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// Struct list read ButtonState +func ButtonStateReadList(buf []byte, dest []ButtonState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ButtonState{} + b += ButtonStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ButtonState +func (v ButtonState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumButtons + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Buttons[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Write struct list ButtonState +func ButtonStateListBytes(buf []byte, list []ButtonState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ButtonState +func ButtonStateListSize(list []ButtonState) int { + size := 0 + for _ = range list { + size += 36 + } + return size +} + +// 'ValuatorState' struct definition +// Size: (4 + xgb.Pad((int(NumValuators) * 4))) +type ValuatorState struct { + ClassId byte + Len byte + NumValuators byte + Mode byte + Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// Struct read ValuatorState +func ValuatorStateRead(buf []byte, v *ValuatorState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.Valuators = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read ValuatorState +func ValuatorStateReadList(buf []byte, dest []ValuatorState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorState{} + b += ValuatorStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ValuatorState +func (v ValuatorState) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.Mode + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list ValuatorState +func ValuatorStateListBytes(buf []byte, list []ValuatorState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ValuatorState +func ValuatorStateListSize(list []ValuatorState) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 'DeviceState' struct definition +// Size: 4 +type DeviceState struct { + ControlId uint16 + Len uint16 +} + +// Struct read DeviceState +func DeviceStateRead(buf []byte, v *DeviceState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read DeviceState +func DeviceStateReadList(buf []byte, dest []DeviceState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceState{} + b += DeviceStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceState +func (v DeviceState) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list DeviceState +func DeviceStateListBytes(buf []byte, list []DeviceState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceResolutionState' struct definition +// Size: (((8 + xgb.Pad((int(NumValuators) * 4))) + xgb.Pad((int(NumValuators) * 4))) + xgb.Pad((int(NumValuators) * 4))) +type DeviceResolutionState struct { + ControlId uint16 + Len uint16 + NumValuators uint32 + ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) + ResolutionMin []uint32 // size: xgb.Pad((int(NumValuators) * 4)) + ResolutionMax []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// Struct read DeviceResolutionState +func DeviceResolutionStateRead(buf []byte, v *DeviceResolutionState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.NumValuators = xgb.Get32(buf[b:]) + b += 4 + + v.ResolutionValues = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionValues[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.ResolutionMin = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionMin[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.ResolutionMax = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionMax[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read DeviceResolutionState +func DeviceResolutionStateReadList(buf []byte, dest []DeviceResolutionState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceResolutionState{} + b += DeviceResolutionStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceResolutionState +func (v DeviceResolutionState) Bytes() []byte { + buf := make([]byte, (((8 + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.NumValuators) + b += 4 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionValues[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionMin[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionMax[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list DeviceResolutionState +func DeviceResolutionStateListBytes(buf []byte, list []DeviceResolutionState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size DeviceResolutionState +func DeviceResolutionStateListSize(list []DeviceResolutionState) int { + size := 0 + for _, item := range list { + size += (((8 + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 'DeviceAbsCalibState' struct definition +// Size: 36 +type DeviceAbsCalibState struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 +} + +// Struct read DeviceAbsCalibState +func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MinX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MinY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.FlipX = xgb.Get32(buf[b:]) + b += 4 + + v.FlipY = xgb.Get32(buf[b:]) + b += 4 + + v.Rotation = xgb.Get32(buf[b:]) + b += 4 + + v.ButtonThreshold = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsCalibState +func DeviceAbsCalibStateReadList(buf []byte, dest []DeviceAbsCalibState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsCalibState{} + b += DeviceAbsCalibStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsCalibState +func (v DeviceAbsCalibState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.MinX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinY)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxY)) + b += 4 + + xgb.Put32(buf[b:], v.FlipX) + b += 4 + + xgb.Put32(buf[b:], v.FlipY) + b += 4 + + xgb.Put32(buf[b:], v.Rotation) + b += 4 + + xgb.Put32(buf[b:], v.ButtonThreshold) + b += 4 + + return buf +} + +// Write struct list DeviceAbsCalibState +func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceAbsAreaState' struct definition +// Size: 28 +type DeviceAbsAreaState struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width uint32 + Height uint32 + Screen uint32 + Following uint32 +} + +// Struct read DeviceAbsAreaState +func DeviceAbsAreaStateRead(buf []byte, v *DeviceAbsAreaState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get32(buf[b:]) + b += 4 + + v.OffsetY = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Screen = xgb.Get32(buf[b:]) + b += 4 + + v.Following = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsAreaState +func DeviceAbsAreaStateReadList(buf []byte, dest []DeviceAbsAreaState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsAreaState{} + b += DeviceAbsAreaStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsAreaState +func (v DeviceAbsAreaState) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.OffsetX) + b += 4 + + xgb.Put32(buf[b:], v.OffsetY) + b += 4 + + xgb.Put32(buf[b:], v.Width) + b += 4 + + xgb.Put32(buf[b:], v.Height) + b += 4 + + xgb.Put32(buf[b:], v.Screen) + b += 4 + + xgb.Put32(buf[b:], v.Following) + b += 4 + + return buf +} + +// Write struct list DeviceAbsAreaState +func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceCoreState' struct definition +// Size: 8 +type DeviceCoreState struct { + ControlId uint16 + Len uint16 + Status byte + Iscore byte + // padding: 2 bytes +} + +// Struct read DeviceCoreState +func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Status = buf[b] + b += 1 + + v.Iscore = buf[b] + b += 1 + + b += 2 // padding + + return b +} + +// Struct list read DeviceCoreState +func DeviceCoreStateReadList(buf []byte, dest []DeviceCoreState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCoreState{} + b += DeviceCoreStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceCoreState +func (v DeviceCoreState) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Status + b += 1 + + buf[b] = v.Iscore + b += 1 + + b += 2 // padding + + return buf +} + +// Write struct list DeviceCoreState +func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceEnableState' struct definition +// Size: 8 +type DeviceEnableState struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes +} + +// Struct read DeviceEnableState +func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Enable = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read DeviceEnableState +func DeviceEnableStateReadList(buf []byte, dest []DeviceEnableState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceEnableState{} + b += DeviceEnableStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceEnableState +func (v DeviceEnableState) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Enable + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list DeviceEnableState +func DeviceEnableStateListBytes(buf []byte, list []DeviceEnableState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceCtl' struct definition +// Size: 4 +type DeviceCtl struct { + ControlId uint16 + Len uint16 +} + +// Struct read DeviceCtl +func DeviceCtlRead(buf []byte, v *DeviceCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read DeviceCtl +func DeviceCtlReadList(buf []byte, dest []DeviceCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCtl{} + b += DeviceCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceCtl +func (v DeviceCtl) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list DeviceCtl +func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceResolutionCtl' struct definition +// Size: (6 + xgb.Pad((int(NumValuators) * 4))) +type DeviceResolutionCtl struct { + ControlId uint16 + Len uint16 + FirstValuator byte + NumValuators byte + ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// Struct read DeviceResolutionCtl +func DeviceResolutionCtlRead(buf []byte, v *DeviceResolutionCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.FirstValuator = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.ResolutionValues = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionValues[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read DeviceResolutionCtl +func DeviceResolutionCtlReadList(buf []byte, dest []DeviceResolutionCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceResolutionCtl{} + b += DeviceResolutionCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceResolutionCtl +func (v DeviceResolutionCtl) Bytes() []byte { + buf := make([]byte, (6 + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.FirstValuator + b += 1 + + buf[b] = v.NumValuators + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionValues[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list DeviceResolutionCtl +func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size DeviceResolutionCtl +func DeviceResolutionCtlListSize(list []DeviceResolutionCtl) int { + size := 0 + for _, item := range list { + size += (6 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 'DeviceAbsCalibCtl' struct definition +// Size: 36 +type DeviceAbsCalibCtl struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 +} + +// Struct read DeviceAbsCalibCtl +func DeviceAbsCalibCtlRead(buf []byte, v *DeviceAbsCalibCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MinX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MinY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.FlipX = xgb.Get32(buf[b:]) + b += 4 + + v.FlipY = xgb.Get32(buf[b:]) + b += 4 + + v.Rotation = xgb.Get32(buf[b:]) + b += 4 + + v.ButtonThreshold = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsCalibCtl +func DeviceAbsCalibCtlReadList(buf []byte, dest []DeviceAbsCalibCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsCalibCtl{} + b += DeviceAbsCalibCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsCalibCtl +func (v DeviceAbsCalibCtl) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.MinX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinY)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxY)) + b += 4 + + xgb.Put32(buf[b:], v.FlipX) + b += 4 + + xgb.Put32(buf[b:], v.FlipY) + b += 4 + + xgb.Put32(buf[b:], v.Rotation) + b += 4 + + xgb.Put32(buf[b:], v.ButtonThreshold) + b += 4 + + return buf +} + +// Write struct list DeviceAbsCalibCtl +func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceAbsAreaCtrl' struct definition +// Size: 28 +type DeviceAbsAreaCtrl struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width int32 + Height int32 + Screen int32 + Following uint32 +} + +// Struct read DeviceAbsAreaCtrl +func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get32(buf[b:]) + b += 4 + + v.OffsetY = xgb.Get32(buf[b:]) + b += 4 + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Screen = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Following = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsAreaCtrl +func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsAreaCtrl{} + b += DeviceAbsAreaCtrlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsAreaCtrl +func (v DeviceAbsAreaCtrl) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.OffsetX) + b += 4 + + xgb.Put32(buf[b:], v.OffsetY) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Width)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Height)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Screen)) + b += 4 + + xgb.Put32(buf[b:], v.Following) + b += 4 + + return buf +} + +// Write struct list DeviceAbsAreaCtrl +func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceCoreCtrl' struct definition +// Size: 8 +type DeviceCoreCtrl struct { + ControlId uint16 + Len uint16 + Status byte + // padding: 3 bytes +} + +// Struct read DeviceCoreCtrl +func DeviceCoreCtrlRead(buf []byte, v *DeviceCoreCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Status = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read DeviceCoreCtrl +func DeviceCoreCtrlReadList(buf []byte, dest []DeviceCoreCtrl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCoreCtrl{} + b += DeviceCoreCtrlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceCoreCtrl +func (v DeviceCoreCtrl) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Status + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list DeviceCoreCtrl +func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceEnableCtrl' struct definition +// Size: 8 +type DeviceEnableCtrl struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes +} + +// Struct read DeviceEnableCtrl +func DeviceEnableCtrlRead(buf []byte, v *DeviceEnableCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Enable = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read DeviceEnableCtrl +func DeviceEnableCtrlReadList(buf []byte, dest []DeviceEnableCtrl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceEnableCtrl{} + b += DeviceEnableCtrlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceEnableCtrl +func (v DeviceEnableCtrl) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Enable + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list DeviceEnableCtrl +func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Event definition DeviceValuator (0) +// Size: 32 + +const DeviceValuator = 0 + +type DeviceValuatorEvent struct { + Sequence uint16 + DeviceId byte + DeviceState uint16 + NumValuators byte + FirstValuator byte + Valuators []int32 // size: 24 +} + +// Event read DeviceValuator +func DeviceValuatorEventNew(buf []byte) xgb.Event { + v := DeviceValuatorEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.DeviceState = xgb.Get16(buf[b:]) + b += 2 + + v.NumValuators = buf[b] + b += 1 + + v.FirstValuator = buf[b] + b += 1 + + v.Valuators = make([]int32, 6) + for i := 0; i < int(6); i++ { + v.Valuators[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Event write DeviceValuator +func (v DeviceValuatorEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put16(buf[b:], v.DeviceState) + b += 2 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.FirstValuator + b += 1 + + for i := 0; i < int(6); i++ { + xgb.Put32(buf[b:], uint32(v.Valuators[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +func (v DeviceValuatorEvent) ImplementsEvent() {} + +func (v DeviceValuatorEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceValuatorEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceState: %d", v.DeviceState)) + fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstValuator: %d", v.FirstValuator)) + return "DeviceValuator {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew +} + +// Event definition DeviceKeyPress (1) +// Size: 32 + +const DeviceKeyPress = 1 + +type DeviceKeyPressEvent struct { + Sequence uint16 + Detail byte + Time xproto.Timestamp + Root xproto.Window + Event xproto.Window + Child xproto.Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + DeviceId byte +} + +// Event read DeviceKeyPress +func DeviceKeyPressEventNew(buf []byte) xgb.Event { + v := DeviceKeyPressEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = 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.Event = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.DeviceId = buf[b] + b += 1 + + return v +} + +// Event write DeviceKeyPress +func (v DeviceKeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.DeviceId + b += 1 + + return buf +} + +func (v DeviceKeyPressEvent) ImplementsEvent() {} + +func (v DeviceKeyPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceKeyPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew +} + +// Event definition FocusIn (6) +// Size: 32 + +const FocusIn = 6 + +type FocusInEvent struct { + Sequence uint16 + Detail byte + Time xproto.Timestamp + Window xproto.Window + Mode byte + DeviceId byte + // padding: 18 bytes +} + +// Event read FocusIn +func FocusInEventNew(buf []byte) xgb.Event { + v := FocusInEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] + b += 1 + + v.DeviceId = buf[b] + b += 1 + + b += 18 // padding + + return v +} + +// Event write FocusIn +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 6 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.Mode + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 18 // padding + + return buf +} + +func (v FocusInEvent) ImplementsEvent() {} + +func (v FocusInEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusInEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew +} + +// Event definition DeviceStateNotify (10) +// Size: 32 + +const DeviceStateNotify = 10 + +type DeviceStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Time xproto.Timestamp + NumKeys byte + NumButtons byte + NumValuators byte + ClassesReported byte + Buttons []byte // size: 4 + Keys []byte // size: 4 + Valuators []uint32 // size: 12 +} + +// Event read DeviceStateNotify +func DeviceStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceStateNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumKeys = buf[b] + b += 1 + + v.NumButtons = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.ClassesReported = buf[b] + b += 1 + + v.Buttons = make([]byte, 4) + copy(v.Buttons[:4], buf[b:]) + b += xgb.Pad(int(4)) + + v.Keys = make([]byte, 4) + copy(v.Keys[:4], buf[b:]) + b += xgb.Pad(int(4)) + + v.Valuators = make([]uint32, 3) + for i := 0; i < int(3); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Event write DeviceStateNotify +func (v DeviceStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 10 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.NumKeys + b += 1 + + buf[b] = v.NumButtons + b += 1 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.ClassesReported + b += 1 + + copy(buf[b:], v.Buttons[:4]) + b += xgb.Pad(int(4)) + + copy(buf[b:], v.Keys[:4]) + b += xgb.Pad(int(4)) + + for i := 0; i < int(3); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +func (v DeviceStateNotifyEvent) ImplementsEvent() {} + +func (v DeviceStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 9) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("NumKeys: %d", v.NumKeys)) + fieldVals = append(fieldVals, xgb.Sprintf("NumButtons: %d", v.NumButtons)) + fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) + fieldVals = append(fieldVals, xgb.Sprintf("ClassesReported: %d", v.ClassesReported)) + return "DeviceStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][10] = DeviceStateNotifyEventNew +} + +// Event definition DeviceMappingNotify (11) +// Size: 32 + +const DeviceMappingNotify = 11 + +type DeviceMappingNotifyEvent struct { + Sequence uint16 + DeviceId byte + Request byte + FirstKeycode KeyCode + Count byte + // padding: 1 bytes + Time xproto.Timestamp + // padding: 20 bytes +} + +// Event read DeviceMappingNotify +func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { + v := DeviceMappingNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = KeyCode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Event write DeviceMappingNotify +func (v DeviceMappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 11 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + b += 20 // padding + + return buf +} + +func (v DeviceMappingNotifyEvent) ImplementsEvent() {} + +func (v DeviceMappingNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceMappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + return "DeviceMappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew +} + +// Event definition ChangeDeviceNotify (12) +// Size: 32 + +const ChangeDeviceNotify = 12 + +type ChangeDeviceNotifyEvent struct { + Sequence uint16 + DeviceId byte + Time xproto.Timestamp + Request byte + // padding: 23 bytes +} + +// Event read ChangeDeviceNotify +func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { + v := ChangeDeviceNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Request = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Event write ChangeDeviceNotify +func (v ChangeDeviceNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Request + b += 1 + + b += 23 // padding + + return buf +} + +func (v ChangeDeviceNotifyEvent) ImplementsEvent() {} + +func (v ChangeDeviceNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ChangeDeviceNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + return "ChangeDeviceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew +} + +// Event definition DeviceKeyStateNotify (13) +// Size: 32 + +const DeviceKeyStateNotify = 13 + +type DeviceKeyStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Keys []byte // size: 28 +} + +// Event read DeviceKeyStateNotify +func DeviceKeyStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceKeyStateNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Keys = make([]byte, 28) + copy(v.Keys[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v +} + +// Event write DeviceKeyStateNotify +func (v DeviceKeyStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + copy(buf[b:], v.Keys[:28]) + b += xgb.Pad(int(28)) + + return buf +} + +func (v DeviceKeyStateNotifyEvent) ImplementsEvent() {} + +func (v DeviceKeyStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceKeyStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew +} + +// Event definition DeviceButtonStateNotify (14) +// Size: 32 + +const DeviceButtonStateNotify = 14 + +type DeviceButtonStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Buttons []byte // size: 28 +} + +// Event read DeviceButtonStateNotify +func DeviceButtonStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceButtonStateNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Buttons = make([]byte, 28) + copy(v.Buttons[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v +} + +// Event write DeviceButtonStateNotify +func (v DeviceButtonStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + copy(buf[b:], v.Buttons[:28]) + b += xgb.Pad(int(28)) + + return buf +} + +func (v DeviceButtonStateNotifyEvent) ImplementsEvent() {} + +func (v DeviceButtonStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceButtonStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew +} + +// Event definition DevicePresenceNotify (15) +// Size: 32 + +const DevicePresenceNotify = 15 + +type DevicePresenceNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time xproto.Timestamp + Devchange byte + DeviceId byte + Control uint16 + // padding: 20 bytes +} + +// Event read DevicePresenceNotify +func DevicePresenceNotifyEventNew(buf []byte) xgb.Event { + v := DevicePresenceNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Devchange = buf[b] + b += 1 + + v.DeviceId = buf[b] + b += 1 + + v.Control = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Event write DevicePresenceNotify +func (v DevicePresenceNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Devchange + b += 1 + + buf[b] = v.DeviceId + b += 1 + + xgb.Put16(buf[b:], v.Control) + b += 2 + + b += 20 // padding + + return buf +} + +func (v DevicePresenceNotifyEvent) ImplementsEvent() {} + +func (v DevicePresenceNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DevicePresenceNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Devchange: %d", v.Devchange)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) + return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew +} + +// EventCopy definition DeviceKeyRelease (2) + +const DeviceKeyRelease = 2 + +type DeviceKeyReleaseEvent DeviceKeyPressEvent + +func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { + return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceKeyReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceKeyReleaseEvent) ImplementsEvent() {} + +func (v DeviceKeyReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceKeyReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew +} + +// EventCopy definition DeviceButtonPress (3) + +const DeviceButtonPress = 3 + +type DeviceButtonPressEvent DeviceKeyPressEvent + +func DeviceButtonPressEventNew(buf []byte) xgb.Event { + return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceButtonPressEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceButtonPressEvent) ImplementsEvent() {} + +func (v DeviceButtonPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew +} + +// EventCopy definition DeviceButtonRelease (4) + +const DeviceButtonRelease = 4 + +type DeviceButtonReleaseEvent DeviceKeyPressEvent + +func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { + return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceButtonReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceButtonReleaseEvent) ImplementsEvent() {} + +func (v DeviceButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew +} + +// EventCopy definition DeviceMotionNotify (5) + +const DeviceMotionNotify = 5 + +type DeviceMotionNotifyEvent DeviceKeyPressEvent + +func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { + return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceMotionNotifyEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceMotionNotifyEvent) ImplementsEvent() {} + +func (v DeviceMotionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceMotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceMotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew +} + +// EventCopy definition ProximityIn (8) + +const ProximityIn = 8 + +type ProximityInEvent DeviceKeyPressEvent + +func ProximityInEventNew(buf []byte) xgb.Event { + return ProximityInEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v ProximityInEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v ProximityInEvent) ImplementsEvent() {} + +func (v ProximityInEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ProximityInEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "ProximityIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][8] = ProximityInEventNew +} + +// EventCopy definition ProximityOut (9) + +const ProximityOut = 9 + +type ProximityOutEvent DeviceKeyPressEvent + +func ProximityOutEventNew(buf []byte) xgb.Event { + return ProximityOutEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v ProximityOutEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v ProximityOutEvent) ImplementsEvent() {} + +func (v ProximityOutEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ProximityOutEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "ProximityOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew +} + +// EventCopy definition FocusOut (7) + +const FocusOut = 7 + +type FocusOutEvent FocusInEvent + +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) +} + +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} + +func (v FocusOutEvent) ImplementsEvent() {} + +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew +} + +// Error definition Device (0) +// Size: 32 + +const BadDevice = 0 + +type DeviceError struct { + Sequence uint16 + NiceName string +} + +// Error read Device +func DeviceErrorNew(buf []byte) xgb.Error { + v := DeviceError{} + v.NiceName = "Device" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err DeviceError) ImplementsError() {} + +func (err DeviceError) SequenceId() uint16 { + return err.Sequence +} + +func (err DeviceError) BadId() uint32 { + return 0 +} + +func (err DeviceError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadDevice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew +} + +// Error definition Event (1) +// Size: 32 + +const BadEvent = 1 + +type EventError struct { + Sequence uint16 + NiceName string +} + +// Error read Event +func EventErrorNew(buf []byte) xgb.Error { + v := EventError{} + v.NiceName = "Event" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err EventError) ImplementsError() {} + +func (err EventError) SequenceId() uint16 { + return err.Sequence +} + +func (err EventError) BadId() uint32 { + return 0 +} + +func (err EventError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadEvent {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][1] = EventErrorNew +} + +// Error definition Mode (2) +// Size: 32 + +const BadMode = 2 + +type ModeError struct { + Sequence uint16 + NiceName string +} + +// Error read Mode +func ModeErrorNew(buf []byte) xgb.Error { + v := ModeError{} + v.NiceName = "Mode" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ModeError) ImplementsError() {} + +func (err ModeError) SequenceId() uint16 { + return err.Sequence +} + +func (err ModeError) BadId() uint32 { + return 0 +} + +func (err ModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew +} + +// Error definition DeviceBusy (3) +// Size: 32 + +const BadDeviceBusy = 3 + +type DeviceBusyError struct { + Sequence uint16 + NiceName string +} + +// Error read DeviceBusy +func DeviceBusyErrorNew(buf []byte) xgb.Error { + v := DeviceBusyError{} + v.NiceName = "DeviceBusy" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err DeviceBusyError) ImplementsError() {} + +func (err DeviceBusyError) SequenceId() uint16 { + return err.Sequence +} + +func (err DeviceBusyError) BadId() uint32 { + return 0 +} + +func (err DeviceBusyError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadDeviceBusy {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew +} + +// Error definition Class (4) +// Size: 32 + +const BadClass = 4 + +type ClassError struct { + Sequence uint16 + NiceName string +} + +// Error read Class +func ClassErrorNew(buf []byte) xgb.Error { + v := ClassError{} + v.NiceName = "Class" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ClassError) ImplementsError() {} + +func (err ClassError) SequenceId() uint16 { + return err.Sequence +} + +func (err ClassError) BadId() uint32 { + return 0 +} + +func (err ClassError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadClass {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew +} + +// Request GetExtensionVersion +// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +type GetExtensionVersionCookie struct { + *xgb.Cookie +} + +func GetExtensionVersion(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} +} + +func GetExtensionVersionUnchecked(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} +} + +// Request reply for GetExtensionVersion +// size: 32 +type GetExtensionVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajor uint16 + ServerMinor uint16 + Present bool + // padding: 19 bytes +} + +// Waits and reads reply data from request GetExtensionVersion +func (cook GetExtensionVersionCookie) Reply() (*GetExtensionVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getExtensionVersionReply(buf), nil +} + +// Read reply into structure from buffer for GetExtensionVersion +func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { + v := new(GetExtensionVersionReply) + 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 + + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 + + b += 19 // padding + + return v +} + +// Write request to wire for GetExtensionVersion +func getExtensionVersionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request ListInputDevices +// size: 4 +type ListInputDevicesCookie struct { + *xgb.Cookie +} + +func ListInputDevices(c *xgb.Conn) ListInputDevicesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} +} + +func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} +} + +// Request reply for ListInputDevices +// size: (32 + xgb.Pad((int(DevicesLen) * 8))) +type ListInputDevicesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DevicesLen byte + // padding: 23 bytes + Devices []DeviceInfo // size: xgb.Pad((int(DevicesLen) * 8)) +} + +// Waits and reads reply data from request ListInputDevices +func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInputDevicesReply(buf), nil +} + +// Read reply into structure from buffer for ListInputDevices +func listInputDevicesReply(buf []byte) *ListInputDevicesReply { + v := new(ListInputDevicesReply) + 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.DevicesLen = buf[b] + b += 1 + + b += 23 // padding + + v.Devices = make([]DeviceInfo, v.DevicesLen) + b += DeviceInfoReadList(buf[b:], v.Devices) + + return v +} + +// Write request to wire for ListInputDevices +func listInputDevicesRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 OpenDevice +// size: 8 +type OpenDeviceCookie struct { + *xgb.Cookie +} + +func OpenDevice(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} +} + +func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} +} + +// Request reply for OpenDevice +// size: (32 + xgb.Pad((int(NumClasses) * 2))) +type OpenDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes + ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) +} + +// Waits and reads reply data from request OpenDevice +func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return openDeviceReply(buf), nil +} + +// Read reply into structure from buffer for OpenDevice +func openDeviceReply(buf []byte) *OpenDeviceReply { + v := new(OpenDeviceReply) + 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.NumClasses = buf[b] + b += 1 + + b += 23 // padding + + v.ClassInfo = make([]InputClassInfo, v.NumClasses) + b += InputClassInfoReadList(buf[b:], v.ClassInfo) + + return v +} + +// Write request to wire for OpenDevice +func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request CloseDevice +// size: 8 +type CloseDeviceCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseDevice +func CloseDevice(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) + return CloseDeviceCookie{cookie} +} + +func CloseDeviceChecked(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) + return CloseDeviceCookie{cookie} +} + +func (cook CloseDeviceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseDevice +func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceMode +// size: 8 +type SetDeviceModeCookie struct { + *xgb.Cookie +} + +func SetDeviceMode(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} +} + +func SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} +} + +// Request reply for SetDeviceMode +// size: 32 +type SetDeviceModeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceMode +func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceModeReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceMode +func setDeviceModeReply(buf []byte) *SetDeviceModeReply { + v := new(SetDeviceModeReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceMode +func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 + + buf[b] = DeviceId + b += 1 + + buf[b] = Mode + b += 1 + + b += 2 // padding + + return buf +} + +// Request SelectExtensionEvent +// size: xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +type SelectExtensionEventCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectExtensionEvent +func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{cookie} +} + +func SelectExtensionEventChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{cookie} +} + +func (cook SelectExtensionEventCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectExtensionEvent +func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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.Put16(buf[b:], NumClasses) + b += 2 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetSelectedExtensionEvents +// size: 8 +type GetSelectedExtensionEventsCookie struct { + *xgb.Cookie +} + +func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +// Request reply for GetSelectedExtensionEvents +// size: ((32 + xgb.Pad((int(NumThisClasses) * 4))) + xgb.Pad((int(NumAllClasses) * 4))) +type GetSelectedExtensionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumThisClasses uint16 + NumAllClasses uint16 + // padding: 20 bytes + ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) + AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) +} + +// Waits and reads reply data from request GetSelectedExtensionEvents +func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectedExtensionEventsReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectedExtensionEvents +func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { + v := new(GetSelectedExtensionEventsReply) + 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.NumThisClasses = xgb.Get16(buf[b:]) + b += 2 + + v.NumAllClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.ThisClasses = make([]EventClass, v.NumThisClasses) + for i := 0; i < int(v.NumThisClasses); i++ { + v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.AllClasses = make([]EventClass, v.NumAllClasses) + for i := 0; i < int(v.NumAllClasses); i++ { + v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetSelectedExtensionEvents +func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 ChangeDeviceDontPropagateList +// size: xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +type ChangeDeviceDontPropagateListCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeDeviceDontPropagateList +func ChangeDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} +} + +func ChangeDeviceDontPropagateListChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} +} + +func (cook ChangeDeviceDontPropagateListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDeviceDontPropagateList +func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = Mode + b += 1 + + b += 1 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetDeviceDontPropagateList +// size: 8 +type GetDeviceDontPropagateListCookie struct { + *xgb.Cookie +} + +func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} +} + +func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} +} + +// Request reply for GetDeviceDontPropagateList +// size: (32 + xgb.Pad((int(NumClasses) * 4))) +type GetDeviceDontPropagateListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClasses uint16 + // padding: 22 bytes + Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) +} + +// Waits and reads reply data from request GetDeviceDontPropagateList +func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceDontPropagateListReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceDontPropagateList +func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { + v := new(GetDeviceDontPropagateListReply) + 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.NumClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Classes = make([]EventClass, v.NumClasses) + for i := 0; i < int(v.NumClasses); i++ { + v.Classes[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceDontPropagateList +func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetDeviceMotionEvents +// size: 16 +type GetDeviceMotionEventsCookie struct { + *xgb.Cookie +} + +func GetDeviceMotionEvents(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) + return GetDeviceMotionEventsCookie{cookie} +} + +func GetDeviceMotionEventsUnchecked(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) + return GetDeviceMotionEventsCookie{cookie} +} + +// Request reply for GetDeviceMotionEvents +// size: 32 +type GetDeviceMotionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumCoords uint32 + NumAxes byte + DeviceMode byte + // padding: 18 bytes +} + +// Waits and reads reply data from request GetDeviceMotionEvents +func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceMotionEventsReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceMotionEvents +func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { + v := new(GetDeviceMotionEventsReply) + 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.NumCoords = xgb.Get32(buf[b:]) + b += 4 + + v.NumAxes = buf[b] + b += 1 + + v.DeviceMode = buf[b] + b += 1 + + b += 18 // padding + + return v +} + +// Write request to wire for GetDeviceMotionEvents +func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Start)) + b += 4 + + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request ChangeKeyboardDevice +// size: 8 +type ChangeKeyboardDeviceCookie struct { + *xgb.Cookie +} + +func ChangeKeyboardDevice(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} +} + +func ChangeKeyboardDeviceUnchecked(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} +} + +// Request reply for ChangeKeyboardDevice +// size: 32 +type ChangeKeyboardDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request ChangeKeyboardDevice +func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return changeKeyboardDeviceReply(buf), nil +} + +// Read reply into structure from buffer for ChangeKeyboardDevice +func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { + v := new(ChangeKeyboardDeviceReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for ChangeKeyboardDevice +func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request ChangePointerDevice +// size: 8 +type ChangePointerDeviceCookie struct { + *xgb.Cookie +} + +func ChangePointerDevice(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} +} + +func ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} +} + +// Request reply for ChangePointerDevice +// size: 32 +type ChangePointerDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request ChangePointerDevice +func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return changePointerDeviceReply(buf), nil +} + +// Read reply into structure from buffer for ChangePointerDevice +func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { + v := new(ChangePointerDeviceReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for ChangePointerDevice +func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = XAxis + b += 1 + + buf[b] = YAxis + b += 1 + + buf[b] = DeviceId + b += 1 + + b += 1 // padding + + return buf +} + +// Request GrabDevice +// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +type GrabDeviceCookie struct { + *xgb.Cookie +} + +func GrabDevice(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) + return GrabDeviceCookie{cookie} +} + +func GrabDeviceUnchecked(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) + return GrabDeviceCookie{cookie} +} + +// Request reply for GrabDevice +// size: 32 +type GrabDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request GrabDevice +func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabDeviceReply(buf), nil +} + +// Read reply into structure from buffer for GrabDevice +func grabDeviceReply(buf []byte) *GrabDeviceReply { + v := new(GrabDeviceReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for GrabDevice +func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = DeviceId + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UngrabDevice +// size: 12 +type UngrabDeviceCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabDevice +func UngrabDevice(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{cookie} +} + +func UngrabDeviceChecked(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{cookie} +} + +func (cook UngrabDeviceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDevice +func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request GrabDeviceKey +// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +type GrabDeviceKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabDeviceKey +func GrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) + return GrabDeviceKeyCookie{cookie} +} + +func GrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) + return GrabDeviceKeyCookie{cookie} +} + +func (cook GrabDeviceKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabDeviceKey +func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + buf[b] = Key + b += 1 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UngrabDeviceKey +// size: 16 +type UngrabDeviceKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabDeviceKey +func UngrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{cookie} +} + +func UngrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{cookie} +} + +func (cook UngrabDeviceKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDeviceKey +func ungrabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = Key + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + return buf +} + +// Request GrabDeviceButton +// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +type GrabDeviceButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabDeviceButton +func GrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} +} + +func GrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} +} + +func (cook GrabDeviceButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabDeviceButton +func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + buf[b] = GrabbedDevice + b += 1 + + buf[b] = ModifierDevice + b += 1 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = OwnerEvents + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UngrabDeviceButton +// size: 16 +type UngrabDeviceButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabDeviceButton +func UngrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} +} + +func UngrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} +} + +func (cook UngrabDeviceButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDeviceButton +func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + return buf +} + +// Request AllowDeviceEvents +// size: 12 +type AllowDeviceEventsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AllowDeviceEvents +func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} +} + +func AllowDeviceEventsChecked(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} +} + +func (cook AllowDeviceEventsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AllowDeviceEvents +func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = Mode + b += 1 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request GetDeviceFocus +// size: 8 +type GetDeviceFocusCookie struct { + *xgb.Cookie +} + +func GetDeviceFocus(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} +} + +func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} +} + +// Request reply for GetDeviceFocus +// size: 32 +type GetDeviceFocusReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Focus xproto.Window + Time xproto.Timestamp + RevertTo byte + // padding: 15 bytes +} + +// Waits and reads reply data from request GetDeviceFocus +func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceFocusReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceFocus +func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { + v := new(GetDeviceFocusReply) + 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.Focus = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.RevertTo = buf[b] + b += 1 + + b += 15 // padding + + return v +} + +// Write request to wire for GetDeviceFocus +func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceFocus +// size: 16 +type SetDeviceFocusCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDeviceFocus +func SetDeviceFocus(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{cookie} +} + +func SetDeviceFocusChecked(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{cookie} +} + +func (cook SetDeviceFocusCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceFocus +func setDeviceFocusRequest(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = RevertTo + b += 1 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request GetFeedbackControl +// size: 8 +type GetFeedbackControlCookie struct { + *xgb.Cookie +} + +func GetFeedbackControl(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} +} + +func GetFeedbackControlUnchecked(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} +} + +// Request reply for GetFeedbackControl +// size: 32 +type GetFeedbackControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFeedback uint16 + // padding: 22 bytes +} + +// Waits and reads reply data from request GetFeedbackControl +func (cook GetFeedbackControlCookie) Reply() (*GetFeedbackControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFeedbackControlReply(buf), nil +} + +// Read reply into structure from buffer for GetFeedbackControl +func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { + v := new(GetFeedbackControlReply) + 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.NumFeedback = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetFeedbackControl +func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request GetDeviceKeyMapping +// size: 8 +type GetDeviceKeyMappingCookie struct { + *xgb.Cookie +} + +func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +// Request reply for GetDeviceKeyMapping +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetDeviceKeyMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + KeysymsPerKeycode byte + // padding: 23 bytes + Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetDeviceKeyMapping +func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceKeyMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceKeyMapping +func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { + v := new(GetDeviceKeyMappingReply) + 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.KeysymsPerKeycode = buf[b] + b += 1 + + b += 23 // padding + + v.Keysyms = make([]xproto.Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceKeyMapping +func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + + return buf +} + +// Request ChangeDeviceKeyMapping +// size: xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +type ChangeDeviceKeyMappingCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeDeviceKeyMapping +func ChangeDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{cookie} +} + +func ChangeDeviceKeyMappingChecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{cookie} +} + +func (cook ChangeDeviceKeyMappingCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDeviceKeyMapping +func changeDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = KeysymsPerKeycode + b += 1 + + buf[b] = KeycodeCount + b += 1 + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetDeviceModifierMapping +// size: 8 +type GetDeviceModifierMappingCookie struct { + *xgb.Cookie +} + +func GetDeviceModifierMapping(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} +} + +func GetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} +} + +// Request reply for GetDeviceModifierMapping +// size: (32 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1))) +type GetDeviceModifierMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + KeycodesPerModifier byte + // padding: 23 bytes + Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +} + +// Waits and reads reply data from request GetDeviceModifierMapping +func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceModifierMapping +func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { + v := new(GetDeviceModifierMappingReply) + 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.KeycodesPerModifier = buf[b] + b += 1 + + b += 23 // padding + + v.Keymaps = make([]byte, (int(v.KeycodesPerModifier) * 8)) + copy(v.Keymaps[:(int(v.KeycodesPerModifier)*8)], buf[b:]) + b += xgb.Pad(int((int(v.KeycodesPerModifier) * 8))) + + return v +} + +// Write request to wire for GetDeviceModifierMapping +func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceModifierMapping +// size: xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +type SetDeviceModifierMappingCookie struct { + *xgb.Cookie +} + +func SetDeviceModifierMapping(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) + return SetDeviceModifierMappingCookie{cookie} +} + +func SetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) + return SetDeviceModifierMappingCookie{cookie} +} + +// Request reply for SetDeviceModifierMapping +// size: 32 +type SetDeviceModifierMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceModifierMapping +func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceModifierMapping +func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { + v := new(SetDeviceModifierMappingReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceModifierMapping +func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { + size := xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = KeycodesPerModifier + b += 1 + + b += 1 // padding + + copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) + b += xgb.Pad(int((int(KeycodesPerModifier) * 8))) + + return buf +} + +// Request GetDeviceButtonMapping +// size: 8 +type GetDeviceButtonMappingCookie struct { + *xgb.Cookie +} + +func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} +} + +func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} +} + +// Request reply for GetDeviceButtonMapping +// size: (32 + xgb.Pad((int(MapSize) * 1))) +type GetDeviceButtonMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MapSize byte + // padding: 23 bytes + Map []byte // size: xgb.Pad((int(MapSize) * 1)) +} + +// Waits and reads reply data from request GetDeviceButtonMapping +func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceButtonMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceButtonMapping +func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { + v := new(GetDeviceButtonMappingReply) + 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.MapSize = buf[b] + b += 1 + + b += 23 // padding + + v.Map = make([]byte, v.MapSize) + copy(v.Map[:v.MapSize], buf[b:]) + b += xgb.Pad(int(v.MapSize)) + + return v +} + +// Write request to wire for GetDeviceButtonMapping +func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceButtonMapping +// size: xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) +type SetDeviceButtonMappingCookie struct { + *xgb.Cookie +} + +func SetDeviceButtonMapping(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) + return SetDeviceButtonMappingCookie{cookie} +} + +func SetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) + return SetDeviceButtonMappingCookie{cookie} +} + +// Request reply for SetDeviceButtonMapping +// size: 32 +type SetDeviceButtonMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceButtonMapping +func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceButtonMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceButtonMapping +func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { + v := new(SetDeviceButtonMappingReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceButtonMapping +func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = MapSize + b += 1 + + b += 2 // padding + + copy(buf[b:], Map[:MapSize]) + b += xgb.Pad(int(MapSize)) + + return buf +} + +// Request QueryDeviceState +// size: 8 +type QueryDeviceStateCookie struct { + *xgb.Cookie +} + +func QueryDeviceState(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} +} + +func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} +} + +// Request reply for QueryDeviceState +// size: 32 +type QueryDeviceStateReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes +} + +// Waits and reads reply data from request QueryDeviceState +func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryDeviceStateReply(buf), nil +} + +// Read reply into structure from buffer for QueryDeviceState +func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { + v := new(QueryDeviceStateReply) + 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.NumClasses = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for QueryDeviceState +func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SendExtensionEvent +// size: xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) +type SendExtensionEventCookie struct { + *xgb.Cookie +} + +// Write request to wire for SendExtensionEvent +func SendExtensionEvent(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{cookie} +} + +func SendExtensionEventChecked(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{cookie} +} + +func (cook SendExtensionEventCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SendExtensionEvent +func sendExtensionEventRequest(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) []byte { + size := xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 31 // 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(Destination)) + b += 4 + + buf[b] = DeviceId + b += 1 + + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = NumEvents + b += 1 + + b += 3 // padding + + copy(buf[b:], Events[:(int(NumEvents)*32)]) + b += xgb.Pad(int((int(NumEvents) * 32))) + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DeviceBell +// size: 8 +type DeviceBellCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeviceBell +func DeviceBell(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{cookie} +} + +func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{cookie} +} + +func (cook DeviceBellCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeviceBell +func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = FeedbackId + b += 1 + + buf[b] = FeedbackClass + b += 1 + + buf[b] = byte(Percent) + b += 1 + + return buf +} + +// Request SetDeviceValuators +// size: xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) +type SetDeviceValuatorsCookie struct { + *xgb.Cookie +} + +func SetDeviceValuators(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) + return SetDeviceValuatorsCookie{cookie} +} + +func SetDeviceValuatorsUnchecked(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) + return SetDeviceValuatorsCookie{cookie} +} + +// Request reply for SetDeviceValuators +// size: 32 +type SetDeviceValuatorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceValuators +func (cook SetDeviceValuatorsCookie) Reply() (*SetDeviceValuatorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceValuatorsReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceValuators +func setDeviceValuatorsReply(buf []byte) *SetDeviceValuatorsReply { + v := new(SetDeviceValuatorsReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceValuators +func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 33 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = FirstValuator + b += 1 + + buf[b] = NumValuators + b += 1 + + b += 1 // padding + + for i := 0; i < int(NumValuators); i++ { + xgb.Put32(buf[b:], uint32(Valuators[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetDeviceControl +// size: 8 +type GetDeviceControlCookie struct { + *xgb.Cookie +} + +func GetDeviceControl(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} +} + +func GetDeviceControlUnchecked(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} +} + +// Request reply for GetDeviceControl +// size: 32 +type GetDeviceControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request GetDeviceControl +func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceControlReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceControl +func getDeviceControlReply(buf []byte) *GetDeviceControlReply { + v := new(GetDeviceControlReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for GetDeviceControl +func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 34 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ControlId) + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 1 // padding + + return buf +} diff --git a/nexgb/xprint/xprint.go b/nexgb/xprint/xprint.go new file mode 100644 index 0000000..2fcf49f --- /dev/null +++ b/nexgb/xprint/xprint.go @@ -0,0 +1,2164 @@ +package xprint + +/* + This file was generated by xprint.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 XpExtension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 11, "XpExtension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XpExtension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XpExtension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XpExtension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XpExtension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XpExtension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XpExtension"] = 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 ( + GetDocFinished = 0 + GetDocSecondConsumer = 1 +) + +const ( + EvMaskNoEventMask = 0 + EvMaskPrintMask = 1 + EvMaskAttributeMask = 2 +) + +const ( + DetailStartJobNotify = 1 + DetailEndJobNotify = 2 + DetailStartDocNotify = 3 + DetailEndDocNotify = 4 + DetailStartPageNotify = 5 + DetailEndPageNotify = 6 +) + +const ( + AttrJobAttr = 1 + AttrDocAttr = 2 + AttrPageAttr = 3 + AttrPrinterAttr = 4 + AttrServerAttr = 5 + AttrMediumAttr = 6 + AttrSpoolerAttr = 7 +) + +type Pcontext uint32 + +func NewPcontextId(c *xgb.Conn) (Pcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pcontext(id), nil +} + +type String8 byte + +// 'Printer' struct definition +// Size: (((4 + xgb.Pad((int(NameLen) * 1))) + 4) + xgb.Pad((int(DescLen) * 1))) +type Printer struct { + NameLen uint32 + Name []String8 // size: xgb.Pad((int(NameLen) * 1)) + DescLen uint32 + Description []String8 // size: xgb.Pad((int(DescLen) * 1)) +} + +// Struct read Printer +func PrinterRead(buf []byte, v *Printer) int { + b := 0 + + v.NameLen = xgb.Get32(buf[b:]) + b += 4 + + v.Name = make([]String8, v.NameLen) + for i := 0; i < int(v.NameLen); i++ { + v.Name[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + v.DescLen = xgb.Get32(buf[b:]) + b += 4 + + v.Description = make([]String8, v.DescLen) + for i := 0; i < int(v.DescLen); i++ { + v.Description[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read Printer +func PrinterReadList(buf []byte, dest []Printer) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Printer{} + b += PrinterRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Printer +func (v Printer) Bytes() []byte { + buf := make([]byte, (((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + xgb.Pad((int(v.DescLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.NameLen) + b += 4 + + for i := 0; i < int(v.NameLen); i++ { + buf[b] = byte(v.Name[i]) + b += 1 + } + b = xgb.Pad(b) + + xgb.Put32(buf[b:], v.DescLen) + b += 4 + + for i := 0; i < int(v.DescLen); i++ { + buf[b] = byte(v.Description[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list Printer +func PrinterListBytes(buf []byte, list []Printer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Printer +func PrinterListSize(list []Printer) int { + size := 0 + for _, item := range list { + size += (((4 + xgb.Pad((int(item.NameLen) * 1))) + 4) + xgb.Pad((int(item.DescLen) * 1))) + } + return size +} + +// Event definition Notify (0) +// Size: 32 + +const Notify = 0 + +type NotifyEvent struct { + Sequence uint16 + Detail byte + Context Pcontext + Cancel bool +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Context = Pcontext(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.Cancel = true + } else { + v.Cancel = false + } + b += 1 + + 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.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Context)) + b += 4 + + if v.Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) + fieldVals = append(fieldVals, xgb.Sprintf("Cancel: %t", v.Cancel)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew +} + +// Event definition AttributNotify (1) +// Size: 32 + +const AttributNotify = 1 + +type AttributNotifyEvent struct { + Sequence uint16 + Detail byte + Context Pcontext +} + +// Event read AttributNotify +func AttributNotifyEventNew(buf []byte) xgb.Event { + v := AttributNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Context = Pcontext(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write AttributNotify +func (v AttributNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Context)) + b += 4 + + return buf +} + +func (v AttributNotifyEvent) ImplementsEvent() {} + +func (v AttributNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v AttributNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) + return "AttributNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XpExtension"][1] = AttributNotifyEventNew +} + +// Error definition BadContext (0) +// Size: 32 + +const BadBadContext = 0 + +type BadContextError struct { + Sequence uint16 + NiceName string +} + +// Error read BadContext +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError{} + v.NiceName = "BadContext" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadContextError) ImplementsError() {} + +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextError) BadId() uint32 { + return 0 +} + +func (err BadContextError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XpExtension"][0] = BadContextErrorNew +} + +// Error definition BadSequence (1) +// Size: 32 + +const BadBadSequence = 1 + +type BadSequenceError struct { + Sequence uint16 + NiceName string +} + +// Error read BadSequence +func BadSequenceErrorNew(buf []byte) xgb.Error { + v := BadSequenceError{} + v.NiceName = "BadSequence" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadSequenceError) ImplementsError() {} + +func (err BadSequenceError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadSequenceError) BadId() uint32 { + return 0 +} + +func (err BadSequenceError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadSequence {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XpExtension"][1] = BadSequenceErrorNew +} + +// Request PrintQueryVersion +// size: 4 +type PrintQueryVersionCookie struct { + *xgb.Cookie +} + +func PrintQueryVersion(c *xgb.Conn) PrintQueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} +} + +func PrintQueryVersionUnchecked(c *xgb.Conn) PrintQueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} +} + +// Request reply for PrintQueryVersion +// size: 12 +type PrintQueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Waits and reads reply data from request PrintQueryVersion +func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printQueryVersionReply(buf), nil +} + +// Read reply into structure from buffer for PrintQueryVersion +func printQueryVersionReply(buf []byte) *PrintQueryVersionReply { + v := new(PrintQueryVersionReply) + 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 PrintQueryVersion +func printQueryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 PrintGetPrinterList +// size: xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +type PrintGetPrinterListCookie struct { + *xgb.Cookie +} + +func PrintGetPrinterList(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} +} + +func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} +} + +// Request reply for PrintGetPrinterList +// size: (32 + PrinterListSize(Printers)) +type PrintGetPrinterListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ListCount uint32 + // padding: 20 bytes + Printers []Printer // size: PrinterListSize(Printers) +} + +// Waits and reads reply data from request PrintGetPrinterList +func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetPrinterListReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetPrinterList +func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { + v := new(PrintGetPrinterListReply) + 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.ListCount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Printers = make([]Printer, v.ListCount) + b += PrinterReadList(buf[b:], v.Printers) + + return v +} + +// Write request to wire for PrintGetPrinterList +func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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:], PrinterNameLen) + b += 4 + + xgb.Put32(buf[b:], LocaleLen) + b += 4 + + for i := 0; i < int(PrinterNameLen); i++ { + buf[b] = byte(PrinterName[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintRehashPrinterList +// size: 4 +type PrintRehashPrinterListCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintRehashPrinterList +func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +func (cook PrintRehashPrinterListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintRehashPrinterList +func printRehashPrinterListRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreateContext +// size: xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +type CreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContext +func CreateContext(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextChecked(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return CreateContextCookie{cookie} +} + +func (cook CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { + size := xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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:], ContextId) + b += 4 + + xgb.Put32(buf[b:], PrinterNameLen) + b += 4 + + xgb.Put32(buf[b:], LocaleLen) + b += 4 + + for i := 0; i < int(PrinterNameLen); i++ { + buf[b] = byte(PrinterName[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintSetContext +// size: 8 +type PrintSetContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintSetContext +func PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +func PrintSetContextChecked(c *xgb.Conn, Context uint32) PrintSetContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +func (cook PrintSetContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetContext +func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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:], Context) + b += 4 + + return buf +} + +// Request PrintGetContext +// size: 4 +type PrintGetContextCookie struct { + *xgb.Cookie +} + +func PrintGetContext(c *xgb.Conn) PrintGetContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} +} + +func PrintGetContextUnchecked(c *xgb.Conn) PrintGetContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} +} + +// Request reply for PrintGetContext +// size: 12 +type PrintGetContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Context uint32 +} + +// Waits and reads reply data from request PrintGetContext +func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetContextReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetContext +func printGetContextReply(buf []byte) *PrintGetContextReply { + v := new(PrintGetContextReply) + 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.Context = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for PrintGetContext +func printGetContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 PrintDestroyContext +// size: 8 +type PrintDestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintDestroyContext +func PrintDestroyContext(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{cookie} +} + +func PrintDestroyContextChecked(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{cookie} +} + +func (cook PrintDestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintDestroyContext +func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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:], Context) + b += 4 + + return buf +} + +// Request PrintGetScreenOfContext +// size: 4 +type PrintGetScreenOfContextCookie struct { + *xgb.Cookie +} + +func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} +} + +func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} +} + +// Request reply for PrintGetScreenOfContext +// size: 12 +type PrintGetScreenOfContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Root xproto.Window +} + +// Waits and reads reply data from request PrintGetScreenOfContext +func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetScreenOfContextReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetScreenOfContext +func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { + v := new(PrintGetScreenOfContextReply) + 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.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for PrintGetScreenOfContext +func printGetScreenOfContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + return buf +} + +// Request PrintStartJob +// size: 8 +type PrintStartJobCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintStartJob +func PrintStartJob(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} +} + +func PrintStartJobChecked(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} +} + +func (cook PrintStartJobCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartJob +func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + buf[b] = OutputMode + b += 1 + + return buf +} + +// Request PrintEndJob +// size: 8 +type PrintEndJobCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintEndJob +func PrintEndJob(c *xgb.Conn, Cancel bool) PrintEndJobCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printEndJobRequest(c, Cancel), cookie) + return PrintEndJobCookie{cookie} +} + +func PrintEndJobChecked(c *xgb.Conn, Cancel bool) PrintEndJobCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printEndJobRequest(c, Cancel), cookie) + return PrintEndJobCookie{cookie} +} + +func (cook PrintEndJobCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintEndJob +func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request PrintStartDoc +// size: 8 +type PrintStartDocCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintStartDoc +func PrintStartDoc(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} +} + +func PrintStartDocChecked(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} +} + +func (cook PrintStartDocCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartDoc +func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DriverMode + b += 1 + + return buf +} + +// Request PrintEndDoc +// size: 8 +type PrintEndDocCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintEndDoc +func PrintEndDoc(c *xgb.Conn, Cancel bool) PrintEndDocCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{cookie} +} + +func PrintEndDocChecked(c *xgb.Conn, Cancel bool) PrintEndDocCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{cookie} +} + +func (cook PrintEndDocCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintEndDoc +func printEndDocRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request PrintPutDocumentData +// size: xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) +type PrintPutDocumentDataCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintPutDocumentData +func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} +} + +func PrintPutDocumentDataChecked(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} +} + +func (cook PrintPutDocumentDataCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintPutDocumentData +func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte { + size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], LenData) + b += 4 + + xgb.Put16(buf[b:], LenFmt) + b += 2 + + xgb.Put16(buf[b:], LenOptions) + b += 2 + + copy(buf[b:], Data[:LenData]) + b += xgb.Pad(int(LenData)) + + for i := 0; i < int(len(DocFormat)); i++ { + buf[b] = byte(DocFormat[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(len(Options)); i++ { + buf[b] = byte(Options[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintGetDocumentData +// size: 12 +type PrintGetDocumentDataCookie struct { + *xgb.Cookie +} + +func PrintGetDocumentData(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) + return PrintGetDocumentDataCookie{cookie} +} + +func PrintGetDocumentDataUnchecked(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) + return PrintGetDocumentDataCookie{cookie} +} + +// Request reply for PrintGetDocumentData +// size: (32 + xgb.Pad((int(DataLen) * 1))) +type PrintGetDocumentDataReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StatusCode uint32 + FinishedFlag uint32 + DataLen uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad((int(DataLen) * 1)) +} + +// Waits and reads reply data from request PrintGetDocumentData +func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetDocumentDataReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetDocumentData +func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { + v := new(PrintGetDocumentDataReply) + 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.StatusCode = xgb.Get32(buf[b:]) + b += 4 + + v.FinishedFlag = xgb.Get32(buf[b:]) + b += 4 + + v.DataLen = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, v.DataLen) + copy(v.Data[:v.DataLen], buf[b:]) + b += xgb.Pad(int(v.DataLen)) + + return v +} + +// Write request to wire for PrintGetDocumentData +func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], MaxBytes) + b += 4 + + return buf +} + +// Request PrintStartPage +// size: 8 +type PrintStartPageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintStartPage +func PrintStartPage(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printStartPageRequest(c, Window), cookie) + return PrintStartPageCookie{cookie} +} + +func PrintStartPageChecked(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printStartPageRequest(c, Window), cookie) + return PrintStartPageCookie{cookie} +} + +func (cook PrintStartPageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartPage +func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request PrintEndPage +// size: 8 +type PrintEndPageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintEndPage +func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{cookie} +} + +func PrintEndPageChecked(c *xgb.Conn, Cancel bool) PrintEndPageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{cookie} +} + +func (cook PrintEndPageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintEndPage +func printEndPageRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request PrintSelectInput +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) +type PrintSelectInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintSelectInput +func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +func (cook PrintSelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSelectInput +func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + for i := 0; i < xgb.PopCount(int(EventMask)); i++ { + xgb.Put32(buf[b:], EventList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintInputSelected +// size: 8 +type PrintInputSelectedCookie struct { + *xgb.Cookie +} + +func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} +} + +func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} +} + +// Request reply for PrintInputSelected +// size: ((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask)))))) + (4 + xgb.Pad((4 * xgb.PopCount(int(AllEventsMask)))))) +type PrintInputSelectedReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + EventMask uint32 + EventList []uint32 + AllEventsMask uint32 + AllEventsList []uint32 +} + +// Waits and reads reply data from request PrintInputSelected +func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printInputSelectedReply(buf), nil +} + +// Read reply into structure from buffer for PrintInputSelected +func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { + v := new(PrintInputSelectedReply) + 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.EventMask = xgb.Get32(buf[b:]) + b += 4 + + v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask))) + for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ { + v.EventList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.AllEventsMask = xgb.Get32(buf[b:]) + b += 4 + + v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask))) + for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ { + v.AllEventsList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintInputSelected +func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request PrintGetAttributes +// size: 12 +type PrintGetAttributesCookie struct { + *xgb.Cookie +} + +func PrintGetAttributes(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} +} + +func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} +} + +// Request reply for PrintGetAttributes +// size: 33 +type PrintGetAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StringLen uint32 + // padding: 20 bytes + Attributes String8 +} + +// Waits and reads reply data from request PrintGetAttributes +func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetAttributesReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetAttributes +func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { + v := new(PrintGetAttributesReply) + 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.StringLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attributes = String8(buf[b]) + b += 1 + + return v +} + +// Write request to wire for PrintGetAttributes +func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + buf[b] = Pool + b += 1 + + b += 3 // padding + + return buf +} + +// Request PrintGetOneAttributes +// size: xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +type PrintGetOneAttributesCookie struct { + *xgb.Cookie +} + +func PrintGetOneAttributes(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{cookie} +} + +func PrintGetOneAttributesUnchecked(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{cookie} +} + +// Request reply for PrintGetOneAttributes +// size: (32 + xgb.Pad((int(ValueLen) * 1))) +type PrintGetOneAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ValueLen uint32 + // padding: 20 bytes + Value []String8 // size: xgb.Pad((int(ValueLen) * 1)) +} + +// Waits and reads reply data from request PrintGetOneAttributes +func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetOneAttributesReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetOneAttributes +func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { + v := new(PrintGetOneAttributesReply) + 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.ValueLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Value = make([]String8, v.ValueLen) + for i := 0; i < int(v.ValueLen); i++ { + v.Value[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintGetOneAttributes +func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], NameLen) + b += 4 + + buf[b] = Pool + b += 1 + + b += 3 // padding + + for i := 0; i < int(NameLen); i++ { + buf[b] = byte(Name[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintSetAttributes +// size: xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) +type PrintSetAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintSetAttributes +func PrintSetAttributes(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) + return PrintSetAttributesCookie{cookie} +} + +func PrintSetAttributesChecked(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) + return PrintSetAttributesCookie{cookie} +} + +func (cook PrintSetAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetAttributes +func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], StringLen) + b += 4 + + buf[b] = Pool + b += 1 + + buf[b] = Rule + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Attributes)); i++ { + buf[b] = byte(Attributes[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintGetPageDimensions +// size: 8 +type PrintGetPageDimensionsCookie struct { + *xgb.Cookie +} + +func PrintGetPageDimensions(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} +} + +func PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} +} + +// Request reply for PrintGetPageDimensions +// size: 20 +type PrintGetPageDimensionsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint16 + Height uint16 + OffsetX uint16 + OffsetY uint16 + ReproducibleWidth uint16 + ReproducibleHeight uint16 +} + +// Waits and reads reply data from request PrintGetPageDimensions +func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetPageDimensionsReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetPageDimensions +func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { + v := new(PrintGetPageDimensionsReply) + 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.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetY = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintGetPageDimensions +func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request PrintQueryScreens +// size: 4 +type PrintQueryScreensCookie struct { + *xgb.Cookie +} + +func PrintQueryScreens(c *xgb.Conn) PrintQueryScreensCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} +} + +func PrintQueryScreensUnchecked(c *xgb.Conn) PrintQueryScreensCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} +} + +// Request reply for PrintQueryScreens +// size: (32 + xgb.Pad((int(ListCount) * 4))) +type PrintQueryScreensReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ListCount uint32 + // padding: 20 bytes + Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 4)) +} + +// Waits and reads reply data from request PrintQueryScreens +func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printQueryScreensReply(buf), nil +} + +// Read reply into structure from buffer for PrintQueryScreens +func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { + v := new(PrintQueryScreensReply) + 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.ListCount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Roots = make([]xproto.Window, v.ListCount) + for i := 0; i < int(v.ListCount); i++ { + v.Roots[i] = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintQueryScreens +func printQueryScreensRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request PrintSetImageResolution +// size: 12 +type PrintSetImageResolutionCookie struct { + *xgb.Cookie +} + +func PrintSetImageResolution(c *xgb.Conn, Context Pcontext, ImageResolution uint16) PrintSetImageResolutionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printSetImageResolutionRequest(c, Context, ImageResolution), cookie) + return PrintSetImageResolutionCookie{cookie} +} + +func PrintSetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext, ImageResolution uint16) PrintSetImageResolutionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printSetImageResolutionRequest(c, Context, ImageResolution), cookie) + return PrintSetImageResolutionCookie{cookie} +} + +// Request reply for PrintSetImageResolution +// size: 10 +type PrintSetImageResolutionReply struct { + Sequence uint16 + Length uint32 + Status bool + PreviousResolutions uint16 +} + +// Waits and reads reply data from request PrintSetImageResolution +func (cook PrintSetImageResolutionCookie) Reply() (*PrintSetImageResolutionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printSetImageResolutionReply(buf), nil +} + +// Read reply into structure from buffer for PrintSetImageResolution +func printSetImageResolutionReply(buf []byte) *PrintSetImageResolutionReply { + v := new(PrintSetImageResolutionReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.Status = true + } else { + v.Status = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PreviousResolutions = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintSetImageResolution +func printSetImageResolutionRequest(c *xgb.Conn, Context Pcontext, ImageResolution uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put16(buf[b:], ImageResolution) + b += 2 + + return buf +} + +// Request PrintGetImageResolution +// size: 8 +type PrintGetImageResolutionCookie struct { + *xgb.Cookie +} + +func PrintGetImageResolution(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} +} + +func PrintGetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} +} + +// Request reply for PrintGetImageResolution +// size: 10 +type PrintGetImageResolutionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ImageResolution uint16 +} + +// Waits and reads reply data from request PrintGetImageResolution +func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetImageResolutionReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetImageResolution +func printGetImageResolutionReply(buf []byte) *PrintGetImageResolutionReply { + v := new(PrintGetImageResolutionReply) + 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.ImageResolution = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintGetImageResolution +func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go new file mode 100644 index 0000000..2516225 --- /dev/null +++ b/nexgb/xproto/xproto.go @@ -0,0 +1,14347 @@ +package xproto + +/* + This file was generated by xproto.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" +) + +// Setup parses the setup bytes retrieved when +// connecting into a SetupInfo struct. +func Setup(c *xgb.Conn) *SetupInfo { + setup := new(SetupInfo) + SetupInfoRead(c.SetupBytes, setup) + return setup +} + +// DefaultScreen gets the default screen info from SetupInfo. +func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { + return &s.Roots[c.DefaultScreen] +} + +// 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 ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) + +const ( + EventMaskNoEvent = 0 + EventMaskKeyPress = 1 + EventMaskKeyRelease = 2 + EventMaskButtonPress = 4 + EventMaskButtonRelease = 8 + EventMaskEnterWindow = 16 + EventMaskLeaveWindow = 32 + EventMaskPointerMotion = 64 + EventMaskPointerMotionHint = 128 + EventMaskButton1Motion = 256 + EventMaskButton2Motion = 512 + EventMaskButton3Motion = 1024 + EventMaskButton4Motion = 2048 + EventMaskButton5Motion = 4096 + EventMaskButtonMotion = 8192 + EventMaskKeymapState = 16384 + EventMaskExposure = 32768 + EventMaskVisibilityChange = 65536 + EventMaskStructureNotify = 131072 + EventMaskResizeRedirect = 262144 + EventMaskSubstructureNotify = 524288 + EventMaskSubstructureRedirect = 1048576 + EventMaskFocusChange = 2097152 + EventMaskPropertyChange = 4194304 + EventMaskColorMapChange = 8388608 + EventMaskOwnerGrabButton = 16777216 +) + +const ( + BackingStoreNotUseful = 0 + BackingStoreWhenMapped = 1 + BackingStoreAlways = 2 +) + +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +const ( + ModMaskShift = 1 + ModMaskLock = 2 + ModMaskControl = 4 + ModMask1 = 8 + ModMask2 = 16 + ModMask3 = 32 + ModMask4 = 64 + ModMask5 = 128 + ModMaskAny = 32768 +) + +const ( + KeyButMaskShift = 1 + KeyButMaskLock = 2 + KeyButMaskControl = 4 + KeyButMaskMod1 = 8 + KeyButMaskMod2 = 16 + KeyButMaskMod3 = 32 + KeyButMaskMod4 = 64 + KeyButMaskMod5 = 128 + KeyButMaskButton1 = 256 + KeyButMaskButton2 = 512 + KeyButMaskButton3 = 1024 + KeyButMaskButton4 = 2048 + KeyButMaskButton5 = 4096 +) + +const ( + WindowNone = 0 +) + +const ( + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 +) + +const ( + MotionNormal = 0 + MotionHint = 1 +) + +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) + +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) + +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) + +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) + +const ( + TimeCurrentTime = 0 +) + +const ( + AtomNone = 0 + AtomAny = 0 + AtomPrimary = 1 + AtomSecondary = 2 + AtomArc = 3 + AtomAtom = 4 + AtomBitmap = 5 + AtomCardinal = 6 + AtomColormap = 7 + AtomCursor = 8 + AtomCutBuffer0 = 9 + AtomCutBuffer1 = 10 + AtomCutBuffer2 = 11 + AtomCutBuffer3 = 12 + AtomCutBuffer4 = 13 + AtomCutBuffer5 = 14 + AtomCutBuffer6 = 15 + AtomCutBuffer7 = 16 + AtomDrawable = 17 + AtomFont = 18 + AtomInteger = 19 + AtomPixmap = 20 + AtomPoint = 21 + AtomRectangle = 22 + AtomResourceManager = 23 + AtomRgbColorMap = 24 + AtomRgbBestMap = 25 + AtomRgbBlueMap = 26 + AtomRgbDefaultMap = 27 + AtomRgbGrayMap = 28 + AtomRgbGreenMap = 29 + AtomRgbRedMap = 30 + AtomString = 31 + AtomVisualid = 32 + AtomWindow = 33 + AtomWmCommand = 34 + AtomWmHints = 35 + AtomWmClientMachine = 36 + AtomWmIconName = 37 + AtomWmIconSize = 38 + AtomWmName = 39 + AtomWmNormalHints = 40 + AtomWmSizeHints = 41 + AtomWmZoomHints = 42 + AtomMinSpace = 43 + AtomNormSpace = 44 + AtomMaxSpace = 45 + AtomEndSpace = 46 + AtomSuperscriptX = 47 + AtomSuperscriptY = 48 + AtomSubscriptX = 49 + AtomSubscriptY = 50 + AtomUnderlinePosition = 51 + AtomUnderlineThickness = 52 + AtomStrikeoutAscent = 53 + AtomStrikeoutDescent = 54 + AtomItalicAngle = 55 + AtomXHeight = 56 + AtomQuadWidth = 57 + AtomWeight = 58 + AtomPointSize = 59 + AtomResolution = 60 + AtomCopyright = 61 + AtomNotice = 62 + AtomFontName = 63 + AtomFamilyName = 64 + AtomFullName = 65 + AtomCapHeight = 66 + AtomWmClass = 67 + AtomWmTransientFor = 68 +) + +const ( + ColormapStateUninstalled = 0 + ColormapStateInstalled = 1 +) + +const ( + ColormapNone = 0 +) + +const ( + MappingModifier = 0 + MappingKeyboard = 1 + MappingPointer = 2 +) + +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) + +const ( + CwBackPixmap = 1 + CwBackPixel = 2 + CwBorderPixmap = 4 + CwBorderPixel = 8 + CwBitGravity = 16 + CwWinGravity = 32 + CwBackingStore = 64 + CwBackingPlanes = 128 + CwBackingPixel = 256 + CwOverrideRedirect = 512 + CwSaveUnder = 1024 + CwEventMask = 2048 + CwDontPropagate = 4096 + CwColormap = 8192 + CwCursor = 16384 +) + +const ( + BackPixmapNone = 0 + BackPixmapParentRelative = 1 +) + +const ( + GravityBitForget = 0 + GravityWinUnmap = 0 + GravityNorthWest = 1 + GravityNorth = 2 + GravityNorthEast = 3 + GravityWest = 4 + GravityCenter = 5 + GravityEast = 6 + GravitySouthWest = 7 + GravitySouth = 8 + GravitySouthEast = 9 + GravityStatic = 10 +) + +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) + +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) + +const ( + ConfigWindowX = 1 + ConfigWindowY = 2 + ConfigWindowWidth = 4 + ConfigWindowHeight = 8 + ConfigWindowBorderWidth = 16 + ConfigWindowSibling = 32 + ConfigWindowStackMode = 64 +) + +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +const ( + CirculateRaiseLowest = 0 + CirculateLowerHighest = 1 +) + +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + GetPropertyTypeAny = 0 +) + +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) + +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) + +const ( + CursorNone = 0 +) + +const ( + ButtonIndexAny = 0 + ButtonIndex1 = 1 + ButtonIndex2 = 2 + ButtonIndex3 = 3 + ButtonIndex4 = 4 + ButtonIndex5 = 5 +) + +const ( + GrabAny = 0 +) + +const ( + AllowAsyncPointer = 0 + AllowSyncPointer = 1 + AllowReplayPointer = 2 + AllowAsyncKeyboard = 3 + AllowSyncKeyboard = 4 + AllowReplayKeyboard = 5 + AllowAsyncBoth = 6 + AllowSyncBoth = 7 +) + +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) + +const ( + FontDrawLeftToRight = 0 + FontDrawRightToLeft = 1 +) + +const ( + GcFunction = 1 + GcPlaneMask = 2 + GcForeground = 4 + GcBackground = 8 + GcLineWidth = 16 + GcLineStyle = 32 + GcCapStyle = 64 + GcJoinStyle = 128 + GcFillStyle = 256 + GcFillRule = 512 + GcTile = 1024 + GcStipple = 2048 + GcTileStippleOriginX = 4096 + GcTileStippleOriginY = 8192 + GcFont = 16384 + GcSubwindowMode = 32768 + GcGraphicsExposures = 65536 + GcClipOriginX = 131072 + GcClipOriginY = 262144 + GcClipMask = 524288 + GcDashOffset = 1048576 + GcDashList = 2097152 + GcArcMode = 4194304 +) + +const ( + GxClear = 0 + GxAnd = 1 + GxAndReverse = 2 + GxCopy = 3 + GxAndInverted = 4 + GxNoop = 5 + GxXor = 6 + GxOr = 7 + GxNor = 8 + GxEquiv = 9 + GxInvert = 10 + GxOrReverse = 11 + GxCopyInverted = 12 + GxOrInverted = 13 + GxNand = 14 + GxSet = 15 +) + +const ( + LineStyleSolid = 0 + LineStyleOnOffDash = 1 + LineStyleDoubleDash = 2 +) + +const ( + CapStyleNotLast = 0 + CapStyleButt = 1 + CapStyleRound = 2 + CapStyleProjecting = 3 +) + +const ( + JoinStyleMiter = 0 + JoinStyleRound = 1 + JoinStyleBevel = 2 +) + +const ( + FillStyleSolid = 0 + FillStyleTiled = 1 + FillStyleStippled = 2 + FillStyleOpaqueStippled = 3 +) + +const ( + FillRuleEvenOdd = 0 + FillRuleWinding = 1 +) + +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) + +const ( + ArcModeChord = 0 + ArcModePieSlice = 1 +) + +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) + +const ( + CoordModeOrigin = 0 + CoordModePrevious = 1 +) + +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) + +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) + +const ( + ColormapAllocNone = 0 + ColormapAllocAll = 1 +) + +const ( + ColorFlagRed = 1 + ColorFlagGreen = 2 + ColorFlagBlue = 4 +) + +const ( + PixmapNone = 0 +) + +const ( + FontNone = 0 +) + +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) + +const ( + KbKeyClickPercent = 1 + KbBellPercent = 2 + KbBellPitch = 4 + KbBellDuration = 8 + KbLed = 16 + KbLedMode = 32 + KbKey = 64 + KbAutoRepeatMode = 128 +) + +const ( + LedModeOff = 0 + LedModeOn = 1 +) + +const ( + AutoRepeatModeOff = 0 + AutoRepeatModeOn = 1 + AutoRepeatModeDefault = 2 +) + +const ( + BlankingNotPreferred = 0 + BlankingPreferred = 1 + BlankingDefault = 2 +) + +const ( + ExposuresNotAllowed = 0 + ExposuresAllowed = 1 + ExposuresDefault = 2 +) + +const ( + HostModeInsert = 0 + HostModeDelete = 1 +) + +const ( + FamilyInternet = 0 + FamilyDECnet = 1 + FamilyChaos = 2 + FamilyServerInterpreted = 5 + FamilyInternet6 = 6 +) + +const ( + AccessControlDisable = 0 + AccessControlEnable = 1 +) + +const ( + CloseDownDestroyAll = 0 + CloseDownRetainPermanent = 1 + CloseDownRetainTemporary = 2 +) + +const ( + KillAllTemporary = 0 +) + +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) + +const ( + MappingStatusSuccess = 0 + MappingStatusBusy = 1 + MappingStatusFailure = 2 +) + +const ( + MapIndexShift = 0 + MapIndexLock = 1 + MapIndexControl = 2 + MapIndex1 = 3 + MapIndex2 = 4 + MapIndex3 = 5 + MapIndex4 = 6 + MapIndex5 = 7 +) + +type Window uint32 + +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} + +type Pixmap uint32 + +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} + +type Cursor uint32 + +func NewCursorId(c *xgb.Conn) (Cursor, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Cursor(id), nil +} + +type Font uint32 + +func NewFontId(c *xgb.Conn) (Font, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Font(id), nil +} + +type Gcontext uint32 + +func NewGcontextId(c *xgb.Conn) (Gcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Gcontext(id), nil +} + +type Colormap uint32 + +func NewColormapId(c *xgb.Conn) (Colormap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Colormap(id), nil +} + +type Atom uint32 + +func NewAtomId(c *xgb.Conn) (Atom, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Atom(id), nil +} + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +type Fontable uint32 + +func NewFontableId(c *xgb.Conn) (Fontable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fontable(id), nil +} + +type Visualid uint32 + +type Timestamp uint32 + +type Keysym uint32 + +type Keycode byte + +type Button byte + +// 'Char2b' struct definition +// Size: 2 +type Char2b struct { + Byte1 byte + Byte2 byte +} + +// Struct read Char2b +func Char2bRead(buf []byte, v *Char2b) int { + b := 0 + + v.Byte1 = buf[b] + b += 1 + + v.Byte2 = buf[b] + b += 1 + + return b +} + +// Struct list read Char2b +func Char2bReadList(buf []byte, dest []Char2b) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Char2b{} + b += Char2bRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Char2b +func (v Char2b) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.Byte1 + b += 1 + + buf[b] = v.Byte2 + b += 1 + + return buf +} + +// Write struct list Char2b +func Char2bListBytes(buf []byte, list []Char2b) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Point' struct definition +// Size: 4 +type Point struct { + X int16 + Y int16 +} + +// Struct read Point +func PointRead(buf []byte, v *Point) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Point +func PointReadList(buf []byte, dest []Point) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Point{} + b += PointRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Point +func (v Point) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// Write struct list Point +func PointListBytes(buf []byte, list []Point) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Rectangle' struct definition +// Size: 8 +type Rectangle struct { + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// Struct read Rectangle +func RectangleRead(buf []byte, v *Rectangle) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Rectangle +func RectangleReadList(buf []byte, dest []Rectangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rectangle{} + b += RectangleRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rectangle +func (v Rectangle) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list Rectangle +func RectangleListBytes(buf []byte, list []Rectangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Arc' struct definition +// Size: 12 +type Arc struct { + X int16 + Y int16 + Width uint16 + Height uint16 + Angle1 int16 + Angle2 int16 +} + +// Struct read Arc +func ArcRead(buf []byte, v *Arc) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Angle1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Angle2 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Arc +func ArcReadList(buf []byte, dest []Arc) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Arc{} + b += ArcRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Arc +func (v Arc) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle2)) + b += 2 + + return buf +} + +// Write struct list Arc +func ArcListBytes(buf []byte, list []Arc) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Format' struct definition +// Size: 8 +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes +} + +// Struct read Format +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + v.BitsPerPixel = buf[b] + b += 1 + + v.ScanlinePad = buf[b] + b += 1 + + b += 5 // padding + + return b +} + +// Struct list read Format +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Format +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.Depth + b += 1 + + buf[b] = v.BitsPerPixel + b += 1 + + buf[b] = v.ScanlinePad + b += 1 + + b += 5 // padding + + return buf +} + +// Write struct list Format +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'VisualInfo' struct definition +// Size: 24 +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes +} + +// Struct read VisualInfo +func VisualInfoRead(buf []byte, v *VisualInfo) int { + b := 0 + + v.VisualId = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Class = buf[b] + b += 1 + + v.BitsPerRgbValue = buf[b] + b += 1 + + v.ColormapEntries = xgb.Get16(buf[b:]) + b += 2 + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + return b +} + +// Struct list read VisualInfo +func VisualInfoReadList(buf []byte, dest []VisualInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = VisualInfo{} + b += VisualInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write VisualInfo +func (v VisualInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + xgb.Put32(buf[b:], uint32(v.VisualId)) + b += 4 + + buf[b] = v.Class + b += 1 + + buf[b] = v.BitsPerRgbValue + b += 1 + + xgb.Put16(buf[b:], v.ColormapEntries) + b += 2 + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + b += 4 // padding + + return buf +} + +// Write struct list VisualInfo +func VisualInfoListBytes(buf []byte, list []VisualInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DepthInfo' struct definition +// Size: (8 + xgb.Pad((int(VisualsLen) * 24))) +type DepthInfo struct { + Depth byte + // padding: 1 bytes + VisualsLen uint16 + // padding: 4 bytes + Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) +} + +// Struct read DepthInfo +func DepthInfoRead(buf []byte, v *DepthInfo) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.VisualsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += VisualInfoReadList(buf[b:], v.Visuals) + + return b +} + +// Struct list read DepthInfo +func DepthInfoReadList(buf []byte, dest []DepthInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DepthInfo{} + b += DepthInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DepthInfo +func (v DepthInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.VisualsLen) + b += 2 + + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) + + return buf +} + +// Write struct list DepthInfo +func DepthInfoListBytes(buf []byte, list []DepthInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size DepthInfo +func DepthInfoListSize(list []DepthInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) + } + return size +} + +// 'ScreenInfo' struct definition +// Size: (40 + DepthInfoListSize(AllowedDepths)) +type ScreenInfo struct { + Root Window + DefaultColormap Colormap + WhitePixel uint32 + BlackPixel uint32 + CurrentInputMasks uint32 + WidthInPixels uint16 + HeightInPixels uint16 + WidthInMillimeters uint16 + HeightInMillimeters uint16 + MinInstalledMaps uint16 + MaxInstalledMaps uint16 + RootVisual Visualid + BackingStores byte + SaveUnders bool + RootDepth byte + AllowedDepthsLen byte + AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) +} + +// Struct read ScreenInfo +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + v.WhitePixel = xgb.Get32(buf[b:]) + b += 4 + + v.BlackPixel = xgb.Get32(buf[b:]) + b += 4 + + v.CurrentInputMasks = xgb.Get32(buf[b:]) + b += 4 + + v.WidthInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.WidthInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.MinInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.MaxInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.RootVisual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.BackingStores = buf[b] + b += 1 + + if buf[b] == 1 { + v.SaveUnders = true + } else { + v.SaveUnders = false + } + b += 1 + + v.RootDepth = buf[b] + b += 1 + + v.AllowedDepthsLen = buf[b] + b += 1 + + v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) + b += DepthInfoReadList(buf[b:], v.AllowedDepths) + + 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, (40 + DepthInfoListSize(v.AllowedDepths))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 + + xgb.Put32(buf[b:], v.WhitePixel) + b += 4 + + xgb.Put32(buf[b:], v.BlackPixel) + b += 4 + + xgb.Put32(buf[b:], v.CurrentInputMasks) + b += 4 + + xgb.Put16(buf[b:], v.WidthInPixels) + b += 2 + + xgb.Put16(buf[b:], v.HeightInPixels) + b += 2 + + xgb.Put16(buf[b:], v.WidthInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.HeightInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.MinInstalledMaps) + b += 2 + + xgb.Put16(buf[b:], v.MaxInstalledMaps) + b += 2 + + xgb.Put32(buf[b:], uint32(v.RootVisual)) + b += 4 + + buf[b] = v.BackingStores + b += 1 + + if v.SaveUnders { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.RootDepth + b += 1 + + buf[b] = v.AllowedDepthsLen + b += 1 + + b += DepthInfoListBytes(buf[b:], v.AllowedDepths) + + 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 +} + +// Struct list size ScreenInfo +func ScreenInfoListSize(list []ScreenInfo) int { + size := 0 + for _, item := range list { + size += (40 + DepthInfoListSize(item.AllowedDepths)) + } + return size +} + +// 'SetupRequest' struct definition +// Size: ((12 + xgb.Pad((int(AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(AuthorizationProtocolDataLen) * 1))) +type SetupRequest struct { + ByteOrder byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + AuthorizationProtocolNameLen uint16 + AuthorizationProtocolDataLen uint16 + // padding: 2 bytes + AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) + AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) +} + +// Struct read SetupRequest +func SetupRequestRead(buf []byte, v *SetupRequest) int { + b := 0 + + v.ByteOrder = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + } + + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + } + + return b +} + +// Struct list read SetupRequest +func SetupRequestReadList(buf []byte, dest []SetupRequest) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupRequest{} + b += SetupRequestRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupRequest +func (v SetupRequest) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) + b := 0 + + buf[b] = v.ByteOrder + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + + return buf +} + +// Write struct list SetupRequest +func SetupRequestListBytes(buf []byte, list []SetupRequest) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupRequest +func SetupRequestListSize(list []SetupRequest) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) + } + return size +} + +// 'SetupFailed' struct definition +// Size: (8 + xgb.Pad((int(ReasonLen) * 1))) +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: xgb.Pad((int(ReasonLen) * 1)) +} + +// Struct read SetupFailed +func SetupFailedRead(buf []byte, v *SetupFailed) int { + b := 0 + + v.Status = buf[b] + b += 1 + + v.ReasonLen = buf[b] + b += 1 + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int(v.ReasonLen)) + } + + return b +} + +// Struct list read SetupFailed +func SetupFailedReadList(buf []byte, dest []SetupFailed) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupFailed{} + b += SetupFailedRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupFailed +func (v SetupFailed) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + buf[b] = v.ReasonLen + b += 1 + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += xgb.Pad(int(v.ReasonLen)) + + return buf +} + +// Write struct list SetupFailed +func SetupFailedListBytes(buf []byte, list []SetupFailed) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupFailed +func SetupFailedListSize(list []SetupFailed) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) + } + return size +} + +// 'SetupAuthenticate' struct definition +// Size: (8 + xgb.Pad(((int(Length) * 4) * 1))) +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Struct read SetupAuthenticate +func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 5 // padding + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, (int(v.Length) * 4)) + copy(byteString[:(int(v.Length)*4)], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int((int(v.Length) * 4))) + } + + return b +} + +// Struct list read SetupAuthenticate +func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupAuthenticate{} + b += SetupAuthenticateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupAuthenticate +func (v SetupAuthenticate) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 5 // padding + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return buf +} + +// Write struct list SetupAuthenticate +func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupAuthenticate +func SetupAuthenticateListSize(list []SetupAuthenticate) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) + } + return size +} + +// 'SetupInfo' struct definition +// Size: (((40 + xgb.Pad((int(VendorLen) * 1))) + xgb.Pad((int(PixmapFormatsLen) * 8))) + ScreenInfoListSize(Roots)) +type SetupInfo struct { + Status byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + ReleaseNumber uint32 + ResourceIdBase uint32 + ResourceIdMask uint32 + MotionBufferSize uint32 + VendorLen uint16 + MaximumRequestLength uint16 + RootsLen byte + PixmapFormatsLen byte + ImageByteOrder byte + BitmapFormatBitOrder byte + BitmapFormatScanlineUnit byte + BitmapFormatScanlinePad byte + MinKeycode Keycode + MaxKeycode Keycode + // padding: 4 bytes + Vendor string // size: xgb.Pad((int(VendorLen) * 1)) + PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) + Roots []ScreenInfo // size: ScreenInfoListSize(Roots) +} + +// Struct read SetupInfo +func SetupInfoRead(buf []byte, v *SetupInfo) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + v.ReleaseNumber = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceIdBase = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceIdMask = xgb.Get32(buf[b:]) + b += 4 + + v.MotionBufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.VendorLen = xgb.Get16(buf[b:]) + b += 2 + + v.MaximumRequestLength = xgb.Get16(buf[b:]) + b += 2 + + v.RootsLen = buf[b] + b += 1 + + v.PixmapFormatsLen = buf[b] + b += 1 + + v.ImageByteOrder = buf[b] + b += 1 + + v.BitmapFormatBitOrder = buf[b] + b += 1 + + v.BitmapFormatScanlineUnit = buf[b] + b += 1 + + v.BitmapFormatScanlinePad = buf[b] + b += 1 + + v.MinKeycode = Keycode(buf[b]) + b += 1 + + v.MaxKeycode = Keycode(buf[b]) + b += 1 + + b += 4 // padding + + { + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLen)) + } + + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += FormatReadList(buf[b:], v.PixmapFormats) + + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ScreenInfoReadList(buf[b:], v.Roots) + + return b +} + +// Struct list read SetupInfo +func SetupInfoReadList(buf []byte, dest []SetupInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupInfo{} + b += SetupInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupInfo +func (v SetupInfo) Bytes() []byte { + buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + xgb.Put32(buf[b:], v.ReleaseNumber) + b += 4 + + xgb.Put32(buf[b:], v.ResourceIdBase) + b += 4 + + xgb.Put32(buf[b:], v.ResourceIdMask) + b += 4 + + xgb.Put32(buf[b:], v.MotionBufferSize) + b += 4 + + xgb.Put16(buf[b:], v.VendorLen) + b += 2 + + xgb.Put16(buf[b:], v.MaximumRequestLength) + b += 2 + + buf[b] = v.RootsLen + b += 1 + + buf[b] = v.PixmapFormatsLen + b += 1 + + buf[b] = v.ImageByteOrder + b += 1 + + buf[b] = v.BitmapFormatBitOrder + b += 1 + + buf[b] = v.BitmapFormatScanlineUnit + b += 1 + + buf[b] = v.BitmapFormatScanlinePad + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + b += 4 // padding + + copy(buf[b:], v.Vendor[:v.VendorLen]) + b += xgb.Pad(int(v.VendorLen)) + + b += FormatListBytes(buf[b:], v.PixmapFormats) + + b += ScreenInfoListBytes(buf[b:], v.Roots) + + return buf +} + +// Write struct list SetupInfo +func SetupInfoListBytes(buf []byte, list []SetupInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupInfo +func SetupInfoListSize(list []SetupInfo) int { + size := 0 + for _, item := range list { + size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) + } + return size +} + +// 'Timecoord' struct definition +// Size: 8 +type Timecoord struct { + Time Timestamp + X int16 + Y int16 +} + +// Struct read Timecoord +func TimecoordRead(buf []byte, v *Timecoord) int { + b := 0 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Timecoord +func TimecoordReadList(buf []byte, dest []Timecoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Timecoord{} + b += TimecoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Timecoord +func (v Timecoord) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// Write struct list Timecoord +func TimecoordListBytes(buf []byte, list []Timecoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Fontprop' struct definition +// Size: 8 +type Fontprop struct { + Name Atom + Value uint32 +} + +// Struct read Fontprop +func FontpropRead(buf []byte, v *Fontprop) int { + b := 0 + + v.Name = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Value = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Fontprop +func FontpropReadList(buf []byte, dest []Fontprop) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Fontprop{} + b += FontpropRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Fontprop +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + xgb.Put32(buf[b:], v.Value) + b += 4 + + return buf +} + +// Write struct list Fontprop +func FontpropListBytes(buf []byte, list []Fontprop) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Charinfo' struct definition +// Size: 12 +type Charinfo struct { + LeftSideBearing int16 + RightSideBearing int16 + CharacterWidth int16 + Ascent int16 + Descent int16 + Attributes uint16 +} + +// Struct read Charinfo +func CharinfoRead(buf []byte, v *Charinfo) int { + b := 0 + + v.LeftSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RightSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.CharacterWidth = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Ascent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Descent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Attributes = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Charinfo +func CharinfoReadList(buf []byte, dest []Charinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Charinfo{} + b += CharinfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Charinfo +func (v Charinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RightSideBearing)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.CharacterWidth)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Ascent)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Descent)) + b += 2 + + xgb.Put16(buf[b:], v.Attributes) + b += 2 + + return buf +} + +// Write struct list Charinfo +func CharinfoListBytes(buf []byte, list []Charinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Str' struct definition +// Size: (1 + xgb.Pad((int(NameLen) * 1))) +type Str struct { + NameLen byte + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Struct read Str +func StrRead(buf []byte, v *Str) int { + b := 0 + + v.NameLen = buf[b] + b += 1 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b +} + +// Struct list read Str +func StrReadList(buf []byte, dest []Str) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Str{} + b += StrRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Str +func (v Str) Bytes() []byte { + buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + buf[b] = v.NameLen + b += 1 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf +} + +// Write struct list Str +func StrListBytes(buf []byte, list []Str) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Str +func StrListSize(list []Str) int { + size := 0 + for _, item := range list { + size += (1 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} + +// 'Segment' struct definition +// Size: 8 +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 +} + +// Struct read Segment +func SegmentRead(buf []byte, v *Segment) int { + b := 0 + + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y2 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Segment +func SegmentReadList(buf []byte, dest []Segment) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Segment{} + b += SegmentRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Segment +func (v Segment) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X2)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y2)) + b += 2 + + return buf +} + +// Write struct list Segment +func SegmentListBytes(buf []byte, list []Segment) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Coloritem' struct definition +// Size: 12 +type Coloritem struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Flags byte + // padding: 1 bytes +} + +// Struct read Coloritem +func ColoritemRead(buf []byte, v *Coloritem) int { + b := 0 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Flags = buf[b] + b += 1 + + b += 1 // padding + + return b +} + +// Struct list read Coloritem +func ColoritemReadList(buf []byte, dest []Coloritem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Coloritem{} + b += ColoritemRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Coloritem +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) + b += 4 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + buf[b] = v.Flags + b += 1 + + b += 1 // padding + + return buf +} + +// Write struct list Coloritem +func ColoritemListBytes(buf []byte, list []Coloritem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Rgb' struct definition +// Size: 8 +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes +} + +// Struct read Rgb +func RgbRead(buf []byte, v *Rgb) int { + b := 0 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// Struct list read Rgb +func RgbReadList(buf []byte, dest []Rgb) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rgb{} + b += RgbRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rgb +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + b += 2 // padding + + return buf +} + +// Write struct list Rgb +func RgbListBytes(buf []byte, list []Rgb) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Host' struct definition +// Size: (4 + xgb.Pad((int(AddressLen) * 1))) +type Host struct { + Family byte + // padding: 1 bytes + AddressLen uint16 + Address []byte // size: xgb.Pad((int(AddressLen) * 1)) +} + +// Struct read Host +func HostRead(buf []byte, v *Host) int { + b := 0 + + v.Family = buf[b] + b += 1 + + b += 1 // padding + + v.AddressLen = xgb.Get16(buf[b:]) + b += 2 + + v.Address = make([]byte, v.AddressLen) + copy(v.Address[:v.AddressLen], buf[b:]) + b += xgb.Pad(int(v.AddressLen)) + + return b +} + +// Struct list read Host +func HostReadList(buf []byte, dest []Host) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Host{} + b += HostRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Host +func (v Host) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) + b := 0 + + buf[b] = v.Family + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.AddressLen) + b += 2 + + copy(buf[b:], v.Address[:v.AddressLen]) + b += xgb.Pad(int(v.AddressLen)) + + return buf +} + +// Write struct list Host +func HostListBytes(buf []byte, list []Host) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Host +func HostListSize(list []Host) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.AddressLen) * 1))) + } + return size +} + +// Union definition ClientMessageDataUnion +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'ClientMessageDataUnion': +// ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion +// ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion +// ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion +type ClientMessageDataUnion struct { + Data8 []byte // size: 20 + Data16 []uint16 // size: 20 + Data32 []uint32 // size: 20 +} + +// Union constructor for ClientMessageDataUnion for field Data8. +func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) + + copy(buf[b:], Data8[:20]) + b += xgb.Pad(int(20)) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Union constructor for ClientMessageDataUnion for field Data16. +func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) + + for i := 0; i < int(10); i++ { + xgb.Put16(buf[b:], Data16[i]) + b += 2 + } + b = xgb.Pad(b) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Union constructor for ClientMessageDataUnion for field Data32. +func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) + + for i := 0; i < int(5); i++ { + xgb.Put32(buf[b:], Data32[i]) + b += 4 + } + b = xgb.Pad(b) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Union read ClientMessageDataUnion +func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { + var b int + + b = 0 // re-read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // re-read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // re-read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return 20 +} + +// Union list read ClientMessageDataUnion +func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Union write ClientMessageDataUnion +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v ClientMessageDataUnion) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + copy(buf[b:], v.Data8[:20]) + b += xgb.Pad(int(20)) + return buf +} + +// Union list write ClientMessageDataUnion +func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + return b +} + +// Event definition KeyPress (2) +// Size: 32 + +const KeyPress = 2 + +type KeyPressEvent struct { + Sequence uint16 + Detail Keycode + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read KeyPress +func KeyPressEventNew(buf []byte) xgb.Event { + v := KeyPressEvent{} + b := 1 // don't read event number + + v.Detail = Keycode(buf[b]) + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write KeyPress +func (v KeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 2 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v KeyPressEvent) ImplementsEvent() {} + +func (v KeyPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v KeyPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[2] = KeyPressEventNew +} + +// Event definition ButtonPress (4) +// Size: 32 + +const ButtonPress = 4 + +type ButtonPressEvent struct { + Sequence uint16 + Detail Button + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read ButtonPress +func ButtonPressEventNew(buf []byte) xgb.Event { + v := ButtonPressEvent{} + b := 1 // don't read event number + + v.Detail = Button(buf[b]) + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write ButtonPress +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 4 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v ButtonPressEvent) ImplementsEvent() {} + +func (v ButtonPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[4] = ButtonPressEventNew +} + +// Event definition MotionNotify (6) +// Size: 32 + +const MotionNotify = 6 + +type MotionNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read MotionNotify +func MotionNotifyEventNew(buf []byte) xgb.Event { + v := MotionNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write MotionNotify +func (v MotionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 6 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v MotionNotifyEvent) ImplementsEvent() {} + +func (v MotionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[6] = MotionNotifyEventNew +} + +// Event definition EnterNotify (7) +// Size: 32 + +const EnterNotify = 7 + +type EnterNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + Mode byte + SameScreenFocus byte +} + +// Event read EnterNotify +func EnterNotifyEventNew(buf []byte) xgb.Event { + v := EnterNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + v.Mode = buf[b] + b += 1 + + v.SameScreenFocus = buf[b] + b += 1 + + return v +} + +// Event write EnterNotify +func (v EnterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 7 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + buf[b] = v.Mode + b += 1 + + buf[b] = v.SameScreenFocus + b += 1 + + return buf +} + +func (v EnterNotifyEvent) ImplementsEvent() {} + +func (v EnterNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v EnterNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) + return "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[7] = EnterNotifyEventNew +} + +// Event definition FocusIn (9) +// Size: 32 + +const FocusIn = 9 + +type FocusInEvent struct { + Sequence uint16 + Detail byte + Event Window + Mode byte + // padding: 3 bytes +} + +// Event read FocusIn +func FocusInEventNew(buf []byte) xgb.Event { + v := FocusInEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write FocusIn +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 9 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + buf[b] = v.Mode + b += 1 + + b += 3 // padding + + return buf +} + +func (v FocusInEvent) ImplementsEvent() {} + +func (v FocusInEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusInEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[9] = FocusInEventNew +} + +// Event definition KeymapNotify (11) +// Size: 32 + +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: 32 +} + +// Event read KeymapNotify +func KeymapNotifyEventNew(buf []byte) xgb.Event { + v := KeymapNotifyEvent{} + b := 1 // don't read event number + + v.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += xgb.Pad(int(31)) + + return v +} + +// Event write KeymapNotify +func (v KeymapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 11 + b += 1 + + copy(buf[b:], v.Keys[:31]) + b += xgb.Pad(int(31)) + + return buf +} + +func (v KeymapNotifyEvent) ImplementsEvent() {} + +func (v KeymapNotifyEvent) SequenceId() uint16 { + return uint16(0) +} + +func (v KeymapNotifyEvent) String() string { + fieldVals := make([]string, 0, 1) + return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[11] = KeymapNotifyEventNew +} + +// Event definition Expose (12) +// Size: 32 + +const Expose = 12 + +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes +} + +// Event read Expose +func ExposeEventNew(buf []byte) xgb.Event { + v := ExposeEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Event write Expose +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + b += 2 // padding + + return buf +} + +func (v ExposeEvent) ImplementsEvent() {} + +func (v ExposeEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ExposeEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[12] = ExposeEventNew +} + +// Event definition GraphicsExposure (13) +// Size: 32 + +const GraphicsExposure = 13 + +type GraphicsExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + X uint16 + Y uint16 + Width uint16 + Height uint16 + MinorOpcode uint16 + Count uint16 + MajorOpcode byte + // padding: 3 bytes +} + +// Event read GraphicsExposure +func GraphicsExposureEventNew(buf []byte) xgb.Event { + v := GraphicsExposureEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write GraphicsExposure +func (v GraphicsExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 3 // padding + + return buf +} + +func (v GraphicsExposureEvent) ImplementsEvent() {} + +func (v GraphicsExposureEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v GraphicsExposureEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "GraphicsExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[13] = GraphicsExposureEventNew +} + +// Event definition NoExposure (14) +// Size: 32 + +const NoExposure = 14 + +type NoExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Event read NoExposure +func NoExposureEventNew(buf []byte) xgb.Event { + v := NoExposureEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Event write NoExposure +func (v NoExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 1 // padding + + return buf +} + +func (v NoExposureEvent) ImplementsEvent() {} + +func (v NoExposureEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NoExposureEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[14] = NoExposureEventNew +} + +// Event definition VisibilityNotify (15) +// Size: 32 + +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + State byte + // padding: 3 bytes +} + +// Event read VisibilityNotify +func VisibilityNotifyEventNew(buf []byte) xgb.Event { + v := VisibilityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write VisibilityNotify +func (v VisibilityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v VisibilityNotifyEvent) ImplementsEvent() {} + +func (v VisibilityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v VisibilityNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[15] = VisibilityNotifyEventNew +} + +// Event definition CreateNotify (16) +// Size: 32 + +const CreateNotify = 16 + +type CreateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// Event read CreateNotify +func CreateNotifyEventNew(buf []byte) xgb.Event { + v := CreateNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write CreateNotify +func (v CreateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 16 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.BorderWidth) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v CreateNotifyEvent) ImplementsEvent() {} + +func (v CreateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CreateNotifyEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[16] = CreateNotifyEventNew +} + +// Event definition DestroyNotify (17) +// Size: 32 + +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window +} + +// Event read DestroyNotify +func DestroyNotifyEventNew(buf []byte) xgb.Event { + v := DestroyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write DestroyNotify +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 17 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +func (v DestroyNotifyEvent) ImplementsEvent() {} + +func (v DestroyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DestroyNotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[17] = DestroyNotifyEventNew +} + +// Event definition UnmapNotify (18) +// Size: 32 + +const UnmapNotify = 18 + +type UnmapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + FromConfigure bool + // padding: 3 bytes +} + +// Event read UnmapNotify +func UnmapNotifyEventNew(buf []byte) xgb.Event { + v := UnmapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.FromConfigure = true + } else { + v.FromConfigure = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write UnmapNotify +func (v UnmapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 18 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.FromConfigure { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v UnmapNotifyEvent) ImplementsEvent() {} + +func (v UnmapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v UnmapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) + return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[18] = UnmapNotifyEventNew +} + +// Event definition MapNotify (19) +// Size: 32 + +const MapNotify = 19 + +type MapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + OverrideRedirect bool + // padding: 3 bytes +} + +// Event read MapNotify +func MapNotifyEventNew(buf []byte) xgb.Event { + v := MapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write MapNotify +func (v MapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 19 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v MapNotifyEvent) ImplementsEvent() {} + +func (v MapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[19] = MapNotifyEventNew +} + +// Event definition MapRequest (20) +// Size: 32 + +const MapRequest = 20 + +type MapRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window +} + +// Event read MapRequest +func MapRequestEventNew(buf []byte) xgb.Event { + v := MapRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write MapRequest +func (v MapRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 20 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +func (v MapRequestEvent) ImplementsEvent() {} + +func (v MapRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MapRequestEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[20] = MapRequestEventNew +} + +// Event definition ReparentNotify (21) +// Size: 32 + +const ReparentNotify = 21 + +type ReparentNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + Parent Window + X int16 + Y int16 + OverrideRedirect bool + // padding: 3 bytes +} + +// Event read ReparentNotify +func ReparentNotifyEventNew(buf []byte) xgb.Event { + v := ReparentNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write ReparentNotify +func (v ReparentNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 21 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v ReparentNotifyEvent) ImplementsEvent() {} + +func (v ReparentNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ReparentNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[21] = ReparentNotifyEventNew +} + +// Event definition ConfigureNotify (22) +// Size: 32 + +const ConfigureNotify = 22 + +type ConfigureNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + AboveSibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// Event read ConfigureNotify +func ConfigureNotifyEventNew(buf []byte) xgb.Event { + v := ConfigureNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.AboveSibling = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write ConfigureNotify +func (v ConfigureNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 22 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.AboveSibling)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.BorderWidth) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v ConfigureNotifyEvent) ImplementsEvent() {} + +func (v ConfigureNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ConfigureNotifyEvent) String() string { + fieldVals := make([]string, 0, 11) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[22] = ConfigureNotifyEventNew +} + +// Event definition ConfigureRequest (23) +// Size: 32 + +const ConfigureRequest = 23 + +type ConfigureRequestEvent struct { + Sequence uint16 + StackMode byte + Parent Window + Window Window + Sibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + ValueMask uint16 +} + +// Event read ConfigureRequest +func ConfigureRequestEventNew(buf []byte) xgb.Event { + v := ConfigureRequestEvent{} + b := 1 // don't read event number + + v.StackMode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Sibling = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ValueMask = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ConfigureRequest +func (v ConfigureRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 23 + b += 1 + + buf[b] = v.StackMode + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Sibling)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.BorderWidth) + b += 2 + + xgb.Put16(buf[b:], v.ValueMask) + b += 2 + + return buf +} + +func (v ConfigureRequestEvent) ImplementsEvent() {} + +func (v ConfigureRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ConfigureRequestEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) + return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[23] = ConfigureRequestEventNew +} + +// Event definition GravityNotify (24) +// Size: 32 + +const GravityNotify = 24 + +type GravityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + X int16 + Y int16 +} + +// Event read GravityNotify +func GravityNotifyEventNew(buf []byte) xgb.Event { + v := GravityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Event write GravityNotify +func (v GravityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 24 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +func (v GravityNotifyEvent) ImplementsEvent() {} + +func (v GravityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v GravityNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[24] = GravityNotifyEventNew +} + +// Event definition ResizeRequest (25) +// Size: 32 + +const ResizeRequest = 25 + +type ResizeRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Width uint16 + Height uint16 +} + +// Event read ResizeRequest +func ResizeRequestEventNew(buf []byte) xgb.Event { + v := ResizeRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ResizeRequest +func (v ResizeRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 25 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +func (v ResizeRequestEvent) ImplementsEvent() {} + +func (v ResizeRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ResizeRequestEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[25] = ResizeRequestEventNew +} + +// Event definition CirculateNotify (26) +// Size: 32 + +const CirculateNotify = 26 + +type CirculateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + // padding: 4 bytes + Place byte + // padding: 3 bytes +} + +// Event read CirculateNotify +func CirculateNotifyEventNew(buf []byte) xgb.Event { + v := CirculateNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + b += 4 // padding + + v.Place = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write CirculateNotify +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 26 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + b += 4 // padding + + buf[b] = v.Place + b += 1 + + b += 3 // padding + + return buf +} + +func (v CirculateNotifyEvent) ImplementsEvent() {} + +func (v CirculateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CirculateNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[26] = CirculateNotifyEventNew +} + +// Event definition PropertyNotify (28) +// Size: 32 + +const PropertyNotify = 28 + +type PropertyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Atom Atom + Time Timestamp + State byte + // padding: 3 bytes +} + +// Event read PropertyNotify +func PropertyNotifyEventNew(buf []byte) xgb.Event { + v := PropertyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write PropertyNotify +func (v PropertyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 28 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Atom)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v PropertyNotifyEvent) ImplementsEvent() {} + +func (v PropertyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PropertyNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[28] = PropertyNotifyEventNew +} + +// Event definition SelectionClear (29) +// Size: 32 + +const SelectionClear = 29 + +type SelectionClearEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Window + Selection Atom +} + +// Event read SelectionClear +func SelectionClearEventNew(buf []byte) xgb.Event { + v := SelectionClearEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionClear +func (v SelectionClearEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 29 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + return buf +} + +func (v SelectionClearEvent) ImplementsEvent() {} + +func (v SelectionClearEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionClearEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[29] = SelectionClearEventNew +} + +// Event definition SelectionRequest (30) +// Size: 32 + +const SelectionRequest = 30 + +type SelectionRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Window + Requestor Window + Selection Atom + Target Atom + Property Atom +} + +// Event read SelectionRequest +func SelectionRequestEventNew(buf []byte) xgb.Event { + v := SelectionRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionRequest +func (v SelectionRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 30 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 + + return buf +} + +func (v SelectionRequestEvent) ImplementsEvent() {} + +func (v SelectionRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionRequestEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) + fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) + return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[30] = SelectionRequestEventNew +} + +// Event definition SelectionNotify (31) +// Size: 32 + +const SelectionNotify = 31 + +type SelectionNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Requestor Window + Selection Atom + Target Atom + Property Atom +} + +// Event read SelectionNotify +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionNotify +func (v SelectionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 31 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 + + return buf +} + +func (v SelectionNotifyEvent) ImplementsEvent() {} + +func (v SelectionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) + fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) + return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[31] = SelectionNotifyEventNew +} + +// Event definition ColormapNotify (32) +// Size: 32 + +const ColormapNotify = 32 + +type ColormapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Colormap Colormap + New bool + State byte + // padding: 2 bytes +} + +// Event read ColormapNotify +func ColormapNotifyEventNew(buf []byte) xgb.Event { + v := ColormapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } + b += 1 + + v.State = buf[b] + b += 1 + + b += 2 // padding + + return v +} + +// Event write ColormapNotify +func (v ColormapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 32 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.State + b += 1 + + b += 2 // padding + + return buf +} + +func (v ColormapNotifyEvent) ImplementsEvent() {} + +func (v ColormapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ColormapNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) + fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[32] = ColormapNotifyEventNew +} + +// Event definition ClientMessage (33) +// Size: 32 + +const ClientMessage = 33 + +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Window + Type Atom + Data ClientMessageDataUnion +} + +// Event read ClientMessage +func ClientMessageEventNew(buf []byte) xgb.Event { + v := ClientMessageEvent{} + b := 1 // don't read event number + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Data = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &v.Data) + + return v +} + +// Event write ClientMessage +func (v ClientMessageEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 33 + b += 1 + + buf[b] = v.Format + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Type)) + b += 4 + + { + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + + return buf +} + +func (v ClientMessageEvent) ImplementsEvent() {} + +func (v ClientMessageEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ClientMessageEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) + return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[33] = ClientMessageEventNew +} + +// Event definition MappingNotify (34) +// Size: 32 + +const MappingNotify = 34 + +type MappingNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes +} + +// Event read MappingNotify +func MappingNotifyEventNew(buf []byte) xgb.Event { + v := MappingNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = Keycode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Event write MappingNotify +func (v MappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 34 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + return buf +} + +func (v MappingNotifyEvent) ImplementsEvent() {} + +func (v MappingNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[34] = MappingNotifyEventNew +} + +// EventCopy definition KeyRelease (3) + +const KeyRelease = 3 + +type KeyReleaseEvent KeyPressEvent + +func KeyReleaseEventNew(buf []byte) xgb.Event { + return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) +} + +func (v KeyReleaseEvent) Bytes() []byte { + return KeyPressEvent(v).Bytes() +} + +func (v KeyReleaseEvent) ImplementsEvent() {} + +func (v KeyReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v KeyReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[3] = KeyReleaseEventNew +} + +// EventCopy definition ButtonRelease (5) + +const ButtonRelease = 5 + +type ButtonReleaseEvent ButtonPressEvent + +func ButtonReleaseEventNew(buf []byte) xgb.Event { + return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) +} + +func (v ButtonReleaseEvent) Bytes() []byte { + return ButtonPressEvent(v).Bytes() +} + +func (v ButtonReleaseEvent) ImplementsEvent() {} + +func (v ButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[5] = ButtonReleaseEventNew +} + +// EventCopy definition LeaveNotify (8) + +const LeaveNotify = 8 + +type LeaveNotifyEvent EnterNotifyEvent + +func LeaveNotifyEventNew(buf []byte) xgb.Event { + return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +} + +func (v LeaveNotifyEvent) Bytes() []byte { + return EnterNotifyEvent(v).Bytes() +} + +func (v LeaveNotifyEvent) ImplementsEvent() {} + +func (v LeaveNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v LeaveNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) + return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[8] = LeaveNotifyEventNew +} + +// EventCopy definition FocusOut (10) + +const FocusOut = 10 + +type FocusOutEvent FocusInEvent + +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) +} + +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} + +func (v FocusOutEvent) ImplementsEvent() {} + +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[10] = FocusOutEventNew +} + +// EventCopy definition CirculateRequest (27) + +const CirculateRequest = 27 + +type CirculateRequestEvent CirculateNotifyEvent + +func CirculateRequestEventNew(buf []byte) xgb.Event { + return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) +} + +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() +} + +func (v CirculateRequestEvent) ImplementsEvent() {} + +func (v CirculateRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CirculateRequestEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[27] = CirculateRequestEventNew +} + +// Error definition Request (1) +// Size: 32 + +const BadRequest = 1 + +type RequestError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Error read Request +func RequestErrorNew(buf []byte) xgb.Error { + v := RequestError{} + v.NiceName = "Request" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +func (err RequestError) ImplementsError() {} + +func (err RequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err RequestError) BadId() uint32 { + return err.BadValue +} + +func (err RequestError) 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 "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[1] = RequestErrorNew +} + +// Error definition Value (2) +// Size: 32 + +const BadValue = 2 + +type ValueError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Error read Value +func ValueErrorNew(buf []byte) xgb.Error { + v := ValueError{} + v.NiceName = "Value" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +func (err ValueError) ImplementsError() {} + +func (err ValueError) SequenceId() uint16 { + return err.Sequence +} + +func (err ValueError) BadId() uint32 { + return err.BadValue +} + +func (err ValueError) 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 "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[2] = ValueErrorNew +} + +// ErrorCopy definition Window (3) + +const BadWindow = 3 + +type WindowError ValueError + +func WindowErrorNew(buf []byte) xgb.Error { + v := WindowError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Window" + return v +} + +func (err WindowError) ImplementsError() {} + +func (err WindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err WindowError) BadId() uint32 { + return err.BadValue +} + +func (err WindowError) 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 "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[3] = WindowErrorNew +} + +// ErrorCopy definition Pixmap (4) + +const BadPixmap = 4 + +type PixmapError ValueError + +func PixmapErrorNew(buf []byte) xgb.Error { + v := PixmapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Pixmap" + return v +} + +func (err PixmapError) ImplementsError() {} + +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} + +func (err PixmapError) BadId() uint32 { + return err.BadValue +} + +func (err PixmapError) 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 "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[4] = PixmapErrorNew +} + +// ErrorCopy definition Atom (5) + +const BadAtom = 5 + +type AtomError ValueError + +func AtomErrorNew(buf []byte) xgb.Error { + v := AtomError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Atom" + return v +} + +func (err AtomError) ImplementsError() {} + +func (err AtomError) SequenceId() uint16 { + return err.Sequence +} + +func (err AtomError) BadId() uint32 { + return err.BadValue +} + +func (err AtomError) 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 "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[5] = AtomErrorNew +} + +// ErrorCopy definition Cursor (6) + +const BadCursor = 6 + +type CursorError ValueError + +func CursorErrorNew(buf []byte) xgb.Error { + v := CursorError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Cursor" + return v +} + +func (err CursorError) ImplementsError() {} + +func (err CursorError) SequenceId() uint16 { + return err.Sequence +} + +func (err CursorError) BadId() uint32 { + return err.BadValue +} + +func (err CursorError) 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 "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[6] = CursorErrorNew +} + +// ErrorCopy definition Font (7) + +const BadFont = 7 + +type FontError ValueError + +func FontErrorNew(buf []byte) xgb.Error { + v := FontError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Font" + return v +} + +func (err FontError) ImplementsError() {} + +func (err FontError) SequenceId() uint16 { + return err.Sequence +} + +func (err FontError) BadId() uint32 { + return err.BadValue +} + +func (err FontError) 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 "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[7] = FontErrorNew +} + +// ErrorCopy definition Match (8) + +const BadMatch = 8 + +type MatchError RequestError + +func MatchErrorNew(buf []byte) xgb.Error { + v := MatchError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Match" + return v +} + +func (err MatchError) ImplementsError() {} + +func (err MatchError) SequenceId() uint16 { + return err.Sequence +} + +func (err MatchError) BadId() uint32 { + return err.BadValue +} + +func (err MatchError) 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 "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[8] = MatchErrorNew +} + +// ErrorCopy definition Drawable (9) + +const BadDrawable = 9 + +type DrawableError ValueError + +func DrawableErrorNew(buf []byte) xgb.Error { + v := DrawableError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Drawable" + return v +} + +func (err DrawableError) ImplementsError() {} + +func (err DrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err DrawableError) BadId() uint32 { + return err.BadValue +} + +func (err DrawableError) 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 "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[9] = DrawableErrorNew +} + +// ErrorCopy definition Access (10) + +const BadAccess = 10 + +type AccessError RequestError + +func AccessErrorNew(buf []byte) xgb.Error { + v := AccessError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Access" + return v +} + +func (err AccessError) ImplementsError() {} + +func (err AccessError) SequenceId() uint16 { + return err.Sequence +} + +func (err AccessError) BadId() uint32 { + return err.BadValue +} + +func (err AccessError) 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 "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[10] = AccessErrorNew +} + +// ErrorCopy definition Alloc (11) + +const BadAlloc = 11 + +type AllocError RequestError + +func AllocErrorNew(buf []byte) xgb.Error { + v := AllocError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Alloc" + return v +} + +func (err AllocError) ImplementsError() {} + +func (err AllocError) SequenceId() uint16 { + return err.Sequence +} + +func (err AllocError) BadId() uint32 { + return err.BadValue +} + +func (err AllocError) 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 "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[11] = AllocErrorNew +} + +// ErrorCopy definition Colormap (12) + +const BadColormap = 12 + +type ColormapError ValueError + +func ColormapErrorNew(buf []byte) xgb.Error { + v := ColormapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Colormap" + return v +} + +func (err ColormapError) ImplementsError() {} + +func (err ColormapError) SequenceId() uint16 { + return err.Sequence +} + +func (err ColormapError) BadId() uint32 { + return err.BadValue +} + +func (err ColormapError) 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 "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[12] = ColormapErrorNew +} + +// ErrorCopy definition GContext (13) + +const BadGContext = 13 + +type GContextError ValueError + +func GContextErrorNew(buf []byte) xgb.Error { + v := GContextError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "GContext" + return v +} + +func (err GContextError) ImplementsError() {} + +func (err GContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err GContextError) BadId() uint32 { + return err.BadValue +} + +func (err GContextError) 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 "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[13] = GContextErrorNew +} + +// ErrorCopy definition IDChoice (14) + +const BadIDChoice = 14 + +type IDChoiceError ValueError + +func IDChoiceErrorNew(buf []byte) xgb.Error { + v := IDChoiceError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "IDChoice" + return v +} + +func (err IDChoiceError) ImplementsError() {} + +func (err IDChoiceError) SequenceId() uint16 { + return err.Sequence +} + +func (err IDChoiceError) BadId() uint32 { + return err.BadValue +} + +func (err IDChoiceError) 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 "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[14] = IDChoiceErrorNew +} + +// ErrorCopy definition Name (15) + +const BadName = 15 + +type NameError RequestError + +func NameErrorNew(buf []byte) xgb.Error { + v := NameError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Name" + return v +} + +func (err NameError) ImplementsError() {} + +func (err NameError) SequenceId() uint16 { + return err.Sequence +} + +func (err NameError) BadId() uint32 { + return err.BadValue +} + +func (err NameError) 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 "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[15] = NameErrorNew +} + +// ErrorCopy definition Length (16) + +const BadLength = 16 + +type LengthError RequestError + +func LengthErrorNew(buf []byte) xgb.Error { + v := LengthError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Length" + return v +} + +func (err LengthError) ImplementsError() {} + +func (err LengthError) SequenceId() uint16 { + return err.Sequence +} + +func (err LengthError) BadId() uint32 { + return err.BadValue +} + +func (err LengthError) 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 "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[16] = LengthErrorNew +} + +// ErrorCopy definition Implementation (17) + +const BadImplementation = 17 + +type ImplementationError RequestError + +func ImplementationErrorNew(buf []byte) xgb.Error { + v := ImplementationError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Implementation" + return v +} + +func (err ImplementationError) ImplementsError() {} + +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence +} + +func (err ImplementationError) BadId() uint32 { + return err.BadValue +} + +func (err ImplementationError) 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 "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[17] = ImplementationErrorNew +} + +// Request CreateWindow +// size: xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreateWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateWindow +func CreateWindow(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} +} + +func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} +} + +func (cook CreateWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateWindow +func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 1 // request opcode + b += 1 + + buf[b] = Depth + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Wid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Parent)) + 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 + + xgb.Put16(buf[b:], Class) + b += 2 + + 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 ChangeWindowAttributes +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeWindowAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeWindowAttributes +func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} +} + +func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} +} + +func (cook ChangeWindowAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeWindowAttributes +func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 2 // request opcode + b += 1 + + b += 1 // padding + + 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:], 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 GetWindowAttributes +// size: 8 +type GetWindowAttributesCookie struct { + *xgb.Cookie +} + +func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} +} + +func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} +} + +// Request reply for GetWindowAttributes +// size: 44 +type GetWindowAttributesReply struct { + Sequence uint16 + Length uint32 + BackingStore byte + Visual Visualid + Class uint16 + BitGravity byte + WinGravity byte + BackingPlanes uint32 + BackingPixel uint32 + SaveUnder bool + MapIsInstalled bool + MapState byte + OverrideRedirect bool + Colormap Colormap + AllEventMasks uint32 + YourEventMask uint32 + DoNotPropagateMask uint16 + // padding: 2 bytes +} + +// Waits and reads reply data from request GetWindowAttributes +func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowAttributesReply(buf), nil +} + +// Read reply into structure from buffer for GetWindowAttributes +func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { + v := new(GetWindowAttributesReply) + b := 1 // skip reply determinant + + v.BackingStore = 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 = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Class = xgb.Get16(buf[b:]) + b += 2 + + v.BitGravity = buf[b] + b += 1 + + v.WinGravity = buf[b] + b += 1 + + v.BackingPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.BackingPixel = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.SaveUnder = true + } else { + v.SaveUnder = false + } + b += 1 + + if buf[b] == 1 { + v.MapIsInstalled = true + } else { + v.MapIsInstalled = false + } + b += 1 + + v.MapState = buf[b] + b += 1 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + v.AllEventMasks = xgb.Get32(buf[b:]) + b += 4 + + v.YourEventMask = xgb.Get32(buf[b:]) + b += 4 + + v.DoNotPropagateMask = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Write request to wire for GetWindowAttributes +func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 3 // request opcode + b += 1 + + b += 1 // padding + + 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 DestroyWindow +// size: 8 +type DestroyWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyWindow +func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} + +func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} + +func (cook DestroyWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyWindow +func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 4 // request opcode + b += 1 + + b += 1 // padding + + 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 DestroySubwindows +// size: 8 +type DestroySubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroySubwindows +func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} +} + +func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} +} + +func (cook DestroySubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroySubwindows +func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 5 // request opcode + b += 1 + + b += 1 // padding + + 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 ChangeSaveSet +// size: 8 +type ChangeSaveSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeSaveSet +func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func (cook ChangeSaveSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeSaveSet +func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 6 // request opcode + b += 1 + + buf[b] = Mode + 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 ReparentWindow +// size: 16 +type ReparentWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for ReparentWindow +func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} +} + +func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} +} + +func (cook ReparentWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ReparentWindow +func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 7 // request opcode + b += 1 + + b += 1 // padding + + 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(Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + return buf +} + +// Request MapWindow +// size: 8 +type MapWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for MapWindow +func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} +} + +func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} +} + +func (cook MapWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for MapWindow +func mapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 8 // request opcode + b += 1 + + b += 1 // padding + + 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 MapSubwindows +// size: 8 +type MapSubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for MapSubwindows +func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} +} + +func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} +} + +func (cook MapSubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for MapSubwindows +func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 9 // request opcode + b += 1 + + b += 1 // padding + + 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 UnmapWindow +// size: 8 +type UnmapWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnmapWindow +func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} +} + +func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} +} + +func (cook UnmapWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnmapWindow +func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 10 // request opcode + b += 1 + + b += 1 // padding + + 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 UnmapSubwindows +// size: 8 +type UnmapSubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnmapSubwindows +func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} +} + +func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} +} + +func (cook UnmapSubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnmapSubwindows +func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 11 // request opcode + b += 1 + + b += 1 // padding + + 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 ConfigureWindow +// size: xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ConfigureWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for ConfigureWindow +func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{cookie} +} + +func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{cookie} +} + +func (cook ConfigureWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConfigureWindow +func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { + size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 12 // request opcode + b += 1 + + b += 1 // padding + + 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.Put16(buf[b:], ValueMask) + b += 2 + + b += 2 // padding + + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CirculateWindow +// size: 8 +type CirculateWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CirculateWindow +func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} +} + +func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} +} + +func (cook CirculateWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CirculateWindow +func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 13 // request opcode + b += 1 + + buf[b] = Direction + 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 GetGeometry +// size: 8 +type GetGeometryCookie struct { + *xgb.Cookie +} + +func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} +} + +func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} +} + +// Request reply for GetGeometry +// size: 24 +type GetGeometryReply struct { + Sequence uint16 + Length uint32 + Depth byte + Root Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + // padding: 2 bytes +} + +// Waits and reads reply data from request GetGeometry +func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGeometryReply(buf), nil +} + +// Read reply into structure from buffer for GetGeometry +func getGeometryReply(buf []byte) *GetGeometryReply { + v := new(GetGeometryReply) + 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.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Write request to wire for GetGeometry +func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 14 // request opcode + b += 1 + + b += 1 // padding + + 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 QueryTree +// size: 8 +type QueryTreeCookie struct { + *xgb.Cookie +} + +func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} +} + +func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} +} + +// Request reply for QueryTree +// size: (32 + xgb.Pad((int(ChildrenLen) * 4))) +type QueryTreeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Root Window + Parent Window + ChildrenLen uint16 + // padding: 14 bytes + Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) +} + +// Waits and reads reply data from request QueryTree +func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryTreeReply(buf), nil +} + +// Read reply into structure from buffer for QueryTree +func queryTreeReply(buf []byte) *QueryTreeReply { + v := new(QueryTreeReply) + 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.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.ChildrenLen = xgb.Get16(buf[b:]) + b += 2 + + b += 14 // padding + + v.Children = make([]Window, v.ChildrenLen) + for i := 0; i < int(v.ChildrenLen); i++ { + v.Children[i] = Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryTree +func queryTreeRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 15 // request opcode + b += 1 + + b += 1 // padding + + 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 InternAtom +// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +type InternAtomCookie struct { + *xgb.Cookie +} + +func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} +} + +func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} +} + +// Request reply for InternAtom +// size: 12 +type InternAtomReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Atom Atom +} + +// Waits and reads reply data from request InternAtom +func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return internAtomReply(buf), nil +} + +// Read reply into structure from buffer for InternAtom +func internAtomReply(buf []byte) *InternAtomReply { + v := new(InternAtomReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for InternAtom +func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 16 // request opcode + b += 1 + + if OnlyIfExists { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request GetAtomName +// size: 8 +type GetAtomNameCookie struct { + *xgb.Cookie +} + +func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} +} + +func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} +} + +// Request reply for GetAtomName +// size: (32 + xgb.Pad((int(NameLen) * 1))) +type GetAtomNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NameLen uint16 + // padding: 22 bytes + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Waits and reads reply data from request GetAtomName +func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getAtomNameReply(buf), nil +} + +// Read reply into structure from buffer for GetAtomName +func getAtomNameReply(buf []byte) *GetAtomNameReply { + v := new(GetAtomNameReply) + 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.NameLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return v +} + +// Write request to wire for GetAtomName +func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 17 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Atom)) + b += 4 + + return buf +} + +// Request ChangeProperty +// size: xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) +type ChangePropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeProperty +func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} + +func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} + +func (cook ChangePropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeProperty +func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 18 // request opcode + b += 1 + + buf[b] = Mode + 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(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) + b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + + return buf +} + +// Request DeleteProperty +// size: 12 +type DeletePropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteProperty +func DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) + return DeletePropertyCookie{cookie} +} + +func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) + return DeletePropertyCookie{cookie} +} + +func (cook DeletePropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteProperty +func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 19 // request opcode + b += 1 + + b += 1 // padding + + 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(Property)) + b += 4 + + return buf +} + +// Request GetProperty +// size: 24 +type GetPropertyCookie struct { + *xgb.Cookie +} + +func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} +} + +func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} +} + +// Request reply for GetProperty +// size: (32 + xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1))) +type GetPropertyReply struct { + Sequence uint16 + Length uint32 + Format byte + Type Atom + BytesAfter uint32 + ValueLen uint32 + // padding: 12 bytes + Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) +} + +// Waits and reads reply data from request GetProperty +func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyReply(buf), nil +} + +// Read reply into structure from buffer for GetProperty +func getPropertyReply(buf []byte) *GetPropertyReply { + v := new(GetPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLen = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) + copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) + + return v +} + +// Write request to wire for GetProperty +func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 20 // request opcode + b += 1 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + 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(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + + return buf +} + +// Request ListProperties +// size: 8 +type ListPropertiesCookie struct { + *xgb.Cookie +} + +func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +// Request reply for ListProperties +// size: (32 + xgb.Pad((int(AtomsLen) * 4))) +type ListPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + AtomsLen uint16 + // padding: 22 bytes + Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) +} + +// Waits and reads reply data from request ListProperties +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listPropertiesReply(buf), nil +} + +// Read reply into structure from buffer for ListProperties +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) + 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.AtomsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Atoms = make([]Atom, v.AtomsLen) + for i := 0; i < int(v.AtomsLen); i++ { + v.Atoms[i] = Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for ListProperties +func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 21 // request opcode + b += 1 + + b += 1 // padding + + 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 SetSelectionOwner +// size: 16 +type SetSelectionOwnerCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetSelectionOwner +func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} +} + +func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} +} + +func (cook SetSelectionOwnerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionOwner +func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 22 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GetSelectionOwner +// size: 8 +type GetSelectionOwnerCookie struct { + *xgb.Cookie +} + +func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +// Request reply for GetSelectionOwner +// size: 12 +type GetSelectionOwnerReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Owner Window +} + +// Waits and reads reply data from request GetSelectionOwner +func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionOwnerReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionOwner +func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { + v := new(GetSelectionOwnerReply) + 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.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetSelectionOwner +func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 23 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + +// Request ConvertSelection +// size: 24 +type ConvertSelectionCookie struct { + *xgb.Cookie +} + +// Write request to wire for ConvertSelection +func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} +} + +func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} +} + +func (cook ConvertSelectionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConvertSelection +func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 24 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request SendEvent +// size: 44 +type SendEventCookie struct { + *xgb.Cookie +} + +// Write request to wire for SendEvent +func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} +} + +func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} +} + +func (cook SendEventCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SendEvent +func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { + size := 44 + b := 0 + buf := make([]byte, size) + + buf[b] = 25 // request opcode + b += 1 + + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + copy(buf[b:], Event[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Request GrabPointer +// size: 24 +type GrabPointerCookie struct { + *xgb.Cookie +} + +func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} +} + +func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} +} + +// Request reply for GrabPointer +// size: 8 +type GrabPointerReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request GrabPointer +func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabPointerReply(buf), nil +} + +// Read reply into structure from buffer for GrabPointer +func grabPointerReply(buf []byte) *GrabPointerReply { + v := new(GrabPointerReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + 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 GrabPointer +func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 26 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request UngrabPointer +// size: 8 +type UngrabPointerCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabPointer +func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} +} + +func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} +} + +func (cook UngrabPointerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPointer +func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 27 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GrabButton +// size: 24 +type GrabButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabButton +func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} +} + +func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} +} + +func (cook GrabButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabButton +func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 28 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + buf[b] = Button + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + return buf +} + +// Request UngrabButton +// size: 12 +type UngrabButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabButton +func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} +} + +func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} +} + +func (cook UngrabButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabButton +func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 29 // request opcode + b += 1 + + buf[b] = Button + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + + return buf +} + +// Request ChangeActivePointerGrab +// size: 16 +type ChangeActivePointerGrabCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeActivePointerGrab +func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} +} + +func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} +} + +func (cook ChangeActivePointerGrabCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeActivePointerGrab +func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 30 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + b += 2 // padding + + return buf +} + +// Request GrabKeyboard +// size: 16 +type GrabKeyboardCookie struct { + *xgb.Cookie +} + +func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} +} + +func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} +} + +// Request reply for GrabKeyboard +// size: 8 +type GrabKeyboardReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request GrabKeyboard +func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabKeyboardReply(buf), nil +} + +// Read reply into structure from buffer for GrabKeyboard +func grabKeyboardReply(buf []byte) *GrabKeyboardReply { + v := new(GrabKeyboardReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + 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 GrabKeyboard +func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 31 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 2 // padding + + return buf +} + +// Request UngrabKeyboard +// size: 8 +type UngrabKeyboardCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabKeyboard +func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} +} + +func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} +} + +func (cook UngrabKeyboardCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabKeyboard +func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 32 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GrabKey +// size: 16 +type GrabKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabKey +func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} +} + +func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} +} + +func (cook GrabKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabKey +func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 33 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = byte(Key) + b += 1 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 3 // padding + + return buf +} + +// Request UngrabKey +// size: 12 +type UngrabKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabKey +func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} +} + +func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} +} + +func (cook UngrabKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabKey +func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 34 // request opcode + b += 1 + + buf[b] = byte(Key) + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + + return buf +} + +// Request AllowEvents +// size: 8 +type AllowEventsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AllowEvents +func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} +} + +func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} +} + +func (cook AllowEventsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AllowEvents +func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 35 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GrabServer +// size: 4 +type GrabServerCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabServer +func GrabServer(c *xgb.Conn) GrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} +} + +func GrabServerChecked(c *xgb.Conn) GrabServerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} +} + +func (cook GrabServerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabServer +func grabServerRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 36 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request UngrabServer +// size: 4 +type UngrabServerCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabServer +func UngrabServer(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} +} + +func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} +} + +func (cook UngrabServerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabServer +func ungrabServerRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 37 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryPointer +// size: 8 +type QueryPointerCookie struct { + *xgb.Cookie +} + +func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} +} + +func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} +} + +// Request reply for QueryPointer +// size: 28 +type QueryPointerReply struct { + Sequence uint16 + Length uint32 + SameScreen bool + Root Window + Child Window + RootX int16 + RootY int16 + WinX int16 + WinY int16 + Mask uint16 + // padding: 2 bytes +} + +// Waits and reads reply data from request QueryPointer +func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPointerReply(buf), nil +} + +// Read reply into structure from buffer for QueryPointer +func queryPointerReply(buf []byte) *QueryPointerReply { + v := new(QueryPointerReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.WinX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.WinY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Mask = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Write request to wire for QueryPointer +func queryPointerRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 38 // request opcode + b += 1 + + b += 1 // padding + + 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 GetMotionEvents +// size: 16 +type GetMotionEventsCookie struct { + *xgb.Cookie +} + +func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +// Request reply for GetMotionEvents +// size: (32 + xgb.Pad((int(EventsLen) * 8))) +type GetMotionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + EventsLen uint32 + // padding: 20 bytes + Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) +} + +// Waits and reads reply data from request GetMotionEvents +func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMotionEventsReply(buf), nil +} + +// Read reply into structure from buffer for GetMotionEvents +func getMotionEventsReply(buf []byte) *GetMotionEventsReply { + v := new(GetMotionEventsReply) + 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.EventsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Events = make([]Timecoord, v.EventsLen) + b += TimecoordReadList(buf[b:], v.Events) + + return v +} + +// Write request to wire for GetMotionEvents +func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 39 // request opcode + b += 1 + + b += 1 // padding + + 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(Start)) + b += 4 + + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 + + return buf +} + +// Request TranslateCoordinates +// size: 16 +type TranslateCoordinatesCookie struct { + *xgb.Cookie +} + +func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} +} + +func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} +} + +// Request reply for TranslateCoordinates +// size: 16 +type TranslateCoordinatesReply struct { + Sequence uint16 + Length uint32 + SameScreen bool + Child Window + DstX int16 + DstY int16 +} + +// Waits and reads reply data from request TranslateCoordinates +func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return translateCoordinatesReply(buf), nil +} + +// Read reply into structure from buffer for TranslateCoordinates +func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { + v := new(TranslateCoordinatesReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.DstX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DstY = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Write request to wire for TranslateCoordinates +func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 40 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + return buf +} + +// Request WarpPointer +// size: 24 +type WarpPointerCookie struct { + *xgb.Cookie +} + +// Write request to wire for WarpPointer +func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} +} + +func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} +} + +func (cook WarpPointerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for WarpPointer +func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 41 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(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 + + return buf +} + +// Request SetInputFocus +// size: 12 +type SetInputFocusCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetInputFocus +func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} +} + +func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} +} + +func (cook SetInputFocusCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetInputFocus +func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 42 // request opcode + b += 1 + + buf[b] = RevertTo + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GetInputFocus +// size: 4 +type GetInputFocusCookie struct { + *xgb.Cookie +} + +func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} +} + +func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} +} + +// Request reply for GetInputFocus +// size: 12 +type GetInputFocusReply struct { + Sequence uint16 + Length uint32 + RevertTo byte + Focus Window +} + +// Waits and reads reply data from request GetInputFocus +func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getInputFocusReply(buf), nil +} + +// Read reply into structure from buffer for GetInputFocus +func getInputFocusReply(buf []byte) *GetInputFocusReply { + v := new(GetInputFocusReply) + b := 1 // skip reply determinant + + v.RevertTo = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Focus = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetInputFocus +func getInputFocusRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 43 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryKeymap +// size: 4 +type QueryKeymapCookie struct { + *xgb.Cookie +} + +func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} +} + +func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} +} + +// Request reply for QueryKeymap +// size: 40 +type QueryKeymapReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Keys []byte // size: 32 +} + +// Waits and reads reply data from request QueryKeymap +func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryKeymapReply(buf), nil +} + +// Read reply into structure from buffer for QueryKeymap +func queryKeymapReply(buf []byte) *QueryKeymapReply { + v := new(QueryKeymapReply) + 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.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for QueryKeymap +func queryKeymapRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 44 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request OpenFont +// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +type OpenFontCookie struct { + *xgb.Cookie +} + +// Write request to wire for OpenFont +func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} +} + +func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} +} + +func (cook OpenFontCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for OpenFont +func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 45 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fid)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request CloseFont +// size: 8 +type CloseFontCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseFont +func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} +} + +func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} +} + +func (cook CloseFontCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseFont +func closeFontRequest(c *xgb.Conn, Font Font) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 46 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + return buf +} + +// Request QueryFont +// size: 8 +type QueryFontCookie struct { + *xgb.Cookie +} + +func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} +} + +func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} +} + +// Request reply for QueryFont +// size: ((60 + xgb.Pad((int(PropertiesLen) * 8))) + xgb.Pad((int(CharInfosLen) * 12))) +type QueryFontReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + CharInfosLen uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) +} + +// Waits and reads reply data from request QueryFont +func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFontReply(buf), nil +} + +// Read reply into structure from buffer for QueryFont +func queryFontReply(buf []byte) *QueryFontReply { + v := new(QueryFontReply) + 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.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.DefaultChar = xgb.Get16(buf[b:]) + b += 2 + + v.PropertiesLen = xgb.Get16(buf[b:]) + b += 2 + + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.CharInfosLen = xgb.Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) + + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += CharinfoReadList(buf[b:], v.CharInfos) + + return v +} + +// Write request to wire for QueryFont +func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 47 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + return buf +} + +// Request QueryTextExtents +// size: xgb.Pad((8 + xgb.Pad((len(String) * 2)))) +type QueryTextExtentsCookie struct { + *xgb.Cookie +} + +func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} +} + +func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} +} + +// Request reply for QueryTextExtents +// size: 28 +type QueryTextExtentsReply struct { + Sequence uint16 + Length uint32 + DrawDirection byte + FontAscent int16 + FontDescent int16 + OverallAscent int16 + OverallDescent int16 + OverallWidth int32 + OverallLeft int32 + OverallRight int32 +} + +// Waits and reads reply data from request QueryTextExtents +func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryTextExtentsReply(buf), nil +} + +// Read reply into structure from buffer for QueryTextExtents +func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { + v := new(QueryTextExtentsReply) + b := 1 // skip reply determinant + + v.DrawDirection = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallWidth = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallLeft = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallRight = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for QueryTextExtents +func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { + size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 48 // request opcode + b += 1 + + buf[b] = byte((int(StringLen) & 1)) + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + b += Char2bListBytes(buf[b:], String) + + // skip writing local field: StringLen (2) :: uint16 + + return buf +} + +// Request ListFonts +// size: xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +type ListFontsCookie struct { + *xgb.Cookie +} + +func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{cookie} +} + +func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{cookie} +} + +// Request reply for ListFonts +// size: (32 + StrListSize(Names)) +type ListFontsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NamesLen uint16 + // padding: 22 bytes + Names []Str // size: StrListSize(Names) +} + +// Waits and reads reply data from request ListFonts +func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listFontsReply(buf), nil +} + +// Read reply into structure from buffer for ListFonts +func listFontsReply(buf []byte) *ListFontsReply { + v := new(ListFontsReply) + 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.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) + + return v +} + +// Write request to wire for ListFonts +func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 49 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], MaxNames) + b += 2 + + xgb.Put16(buf[b:], PatternLen) + b += 2 + + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) + + return buf +} + +// Request ListFontsWithInfo +// size: xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +type ListFontsWithInfoCookie struct { + *xgb.Cookie +} + +func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} +} + +func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} +} + +// Request reply for ListFontsWithInfo +// size: ((60 + xgb.Pad((int(PropertiesLen) * 8))) + xgb.Pad((int(NameLen) * 1))) +type ListFontsWithInfoReply struct { + Sequence uint16 + Length uint32 + NameLen byte + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + RepliesHint uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Waits and reads reply data from request ListFontsWithInfo +func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listFontsWithInfoReply(buf), nil +} + +// Read reply into structure from buffer for ListFontsWithInfo +func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { + v := new(ListFontsWithInfoReply) + b := 1 // skip reply determinant + + v.NameLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.DefaultChar = xgb.Get16(buf[b:]) + b += 2 + + v.PropertiesLen = xgb.Get16(buf[b:]) + b += 2 + + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RepliesHint = xgb.Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return v +} + +// Write request to wire for ListFontsWithInfo +func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 50 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], MaxNames) + b += 2 + + xgb.Put16(buf[b:], PatternLen) + b += 2 + + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) + + return buf +} + +// Request SetFontPath +// size: xgb.Pad((8 + StrListSize(Font))) +type SetFontPathCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetFontPath +func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} +} + +func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} +} + +func (cook SetFontPathCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetFontPath +func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { + size := xgb.Pad((8 + StrListSize(Font))) + b := 0 + buf := make([]byte, size) + + buf[b] = 51 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], FontQty) + b += 2 + + b += 2 // padding + + b += StrListBytes(buf[b:], Font) + + return buf +} + +// Request GetFontPath +// size: 4 +type GetFontPathCookie struct { + *xgb.Cookie +} + +func GetFontPath(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +// Request reply for GetFontPath +// size: (32 + StrListSize(Path)) +type GetFontPathReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PathLen uint16 + // padding: 22 bytes + Path []Str // size: StrListSize(Path) +} + +// Waits and reads reply data from request GetFontPath +func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFontPathReply(buf), nil +} + +// Read reply into structure from buffer for GetFontPath +func getFontPathReply(buf []byte) *GetFontPathReply { + v := new(GetFontPathReply) + 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.PathLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Path = make([]Str, v.PathLen) + b += StrReadList(buf[b:], v.Path) + + return v +} + +// Write request to wire for GetFontPath +func getFontPathRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 52 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreatePixmap +// size: 16 +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePixmap +func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 53 // request opcode + b += 1 + + buf[b] = Depth + 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 + + return buf +} + +// Request FreePixmap +// size: 8 +type FreePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreePixmap +func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +func (cook FreePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreePixmap +func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 54 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + return buf +} + +// Request CreateGC +// size: xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreateGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGC +func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +func (cook CreateGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGC +func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 55 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + 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 ChangeGC +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeGC +func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} +} + +func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} +} + +func (cook ChangeGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeGC +func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 56 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], 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 CopyGC +// size: 16 +type CopyGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyGC +func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +func (cook CopyGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyGC +func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 57 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcGc)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstGc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + + return buf +} + +// Request SetDashes +// size: xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) +type SetDashesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDashes +func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} +} + +func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} +} + +func (cook SetDashesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDashes +func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 58 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], DashOffset) + b += 2 + + xgb.Put16(buf[b:], DashesLen) + b += 2 + + copy(buf[b:], Dashes[:DashesLen]) + b += xgb.Pad(int(DashesLen)) + + return buf +} + +// Request SetClipRectangles +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type SetClipRectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClipRectangles +func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} +} + +func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} +} + +func (cook SetClipRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClipRectangles +func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 59 // request opcode + b += 1 + + buf[b] = Ordering + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(ClipXOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request FreeGC +// size: 8 +type FreeGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeGC +func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} +} + +func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} +} + +func (cook FreeGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGC +func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 60 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + return buf +} + +// Request ClearArea +// size: 16 +type ClearAreaCookie struct { + *xgb.Cookie +} + +// Write request to wire for ClearArea +func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} +} + +func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} +} + +func (cook ClearAreaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ClearArea +func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 61 // request opcode + b += 1 + + if Exposures { + buf[b] = 1 + } else { + buf[b] = 0 + } + 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.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 + + return buf +} + +// Request CopyArea +// size: 28 +type CopyAreaCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyArea +func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} +} + +func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} +} + +func (cook CopyAreaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyArea +func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = 62 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request CopyPlane +// size: 32 +type CopyPlaneCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyPlane +func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} +} + +func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} +} + +func (cook CopyPlaneCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyPlane +func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 63 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], BitPlane) + b += 4 + + return buf +} + +// Request PolyPoint +// size: xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +type PolyPointCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyPoint +func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} +} + +func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} +} + +func (cook PolyPointCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyPoint +func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 64 // request opcode + b += 1 + + buf[b] = CoordinateMode + 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 + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// Request PolyLine +// size: xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +type PolyLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyLine +func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} +} + +func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} +} + +func (cook PolyLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyLine +func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 65 // request opcode + b += 1 + + buf[b] = CoordinateMode + 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 + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// Request PolySegment +// size: xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) +type PolySegmentCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolySegment +func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} +} + +func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} +} + +func (cook PolySegmentCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolySegment +func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 66 // request opcode + b += 1 + + b += 1 // padding + + 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 + + b += SegmentListBytes(buf[b:], Segments) + + return buf +} + +// Request PolyRectangle +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type PolyRectangleCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyRectangle +func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} +} + +func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} +} + +func (cook PolyRectangleCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyRectangle +func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 67 // request opcode + b += 1 + + b += 1 // padding + + 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 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request PolyArc +// size: xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +type PolyArcCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyArc +func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} +} + +func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} +} + +func (cook PolyArcCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyArc +func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 68 // request opcode + b += 1 + + b += 1 // padding + + 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 + + b += ArcListBytes(buf[b:], Arcs) + + return buf +} + +// Request FillPoly +// size: xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) +type FillPolyCookie struct { + *xgb.Cookie +} + +// Write request to wire for FillPoly +func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} +} + +func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} +} + +func (cook FillPolyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FillPoly +func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 69 // request opcode + b += 1 + + b += 1 // padding + + 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 + + buf[b] = Shape + b += 1 + + buf[b] = CoordinateMode + b += 1 + + b += 2 // padding + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// Request PolyFillRectangle +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type PolyFillRectangleCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyFillRectangle +func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} +} + +func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} +} + +func (cook PolyFillRectangleCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyFillRectangle +func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 70 // request opcode + b += 1 + + b += 1 // padding + + 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 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request PolyFillArc +// size: xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +type PolyFillArcCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyFillArc +func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} +} + +func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} +} + +func (cook PolyFillArcCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyFillArc +func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 71 // request opcode + b += 1 + + b += 1 // padding + + 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 + + b += ArcListBytes(buf[b:], Arcs) + + return buf +} + +// Request PutImage +// size: xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) +type PutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutImage +func PutImage(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} +} + +func PutImageChecked(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} +} + +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 72 // request opcode + b += 1 + + buf[b] = Format + 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:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + buf[b] = LeftPad + b += 1 + + buf[b] = Depth + b += 1 + + b += 2 // padding + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request GetImage +// size: 20 +type GetImageCookie struct { + *xgb.Cookie +} + +func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} +} + +func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} +} + +// Request reply for GetImage +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetImageReply struct { + Sequence uint16 + Length uint32 + Depth byte + Visual Visualid + // padding: 20 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// 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 = Visualid(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetImage +func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 73 // request opcode + b += 1 + + buf[b] = Format + 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 + + return buf +} + +// Request PolyText8 +// size: xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +type PolyText8Cookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyText8 +func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} +} + +func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} +} + +func (cook PolyText8Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyText8 +func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 74 // request opcode + b += 1 + + b += 1 // padding + + 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:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) + + return buf +} + +// Request PolyText16 +// size: xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +type PolyText16Cookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyText16 +func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} +} + +func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} +} + +func (cook PolyText16Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyText16 +func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 75 // request opcode + b += 1 + + b += 1 // padding + + 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:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) + + return buf +} + +// Request ImageText8 +// size: xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) +type ImageText8Cookie struct { + *xgb.Cookie +} + +// Write request to wire for ImageText8 +func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} +} + +func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} +} + +func (cook ImageText8Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ImageText8 +func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 76 // request opcode + b += 1 + + buf[b] = StringLen + 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:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], String[:StringLen]) + b += xgb.Pad(int(StringLen)) + + return buf +} + +// Request ImageText16 +// size: xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) +type ImageText16Cookie struct { + *xgb.Cookie +} + +// Write request to wire for ImageText16 +func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} +} + +func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} +} + +func (cook ImageText16Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ImageText16 +func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 77 // request opcode + b += 1 + + buf[b] = StringLen + 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:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + b += Char2bListBytes(buf[b:], String) + + return buf +} + +// Request CreateColormap +// size: 16 +type CreateColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateColormap +func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +func (cook CreateColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateColormap +func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 78 // request opcode + b += 1 + + buf[b] = Alloc + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + return buf +} + +// Request FreeColormap +// size: 8 +type FreeColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeColormap +func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} +} + +func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} +} + +func (cook FreeColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColormap +func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 79 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// Request CopyColormapAndFree +// size: 12 +type CopyColormapAndFreeCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyColormapAndFree +func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +func (cook CopyColormapAndFreeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyColormapAndFree +func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 80 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcCmap)) + b += 4 + + return buf +} + +// Request InstallColormap +// size: 8 +type InstallColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for InstallColormap +func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +func (cook InstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InstallColormap +func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 81 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// Request UninstallColormap +// size: 8 +type UninstallColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for UninstallColormap +func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +func (cook UninstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UninstallColormap +func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 82 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// Request ListInstalledColormaps +// size: 8 +type ListInstalledColormapsCookie struct { + *xgb.Cookie +} + +func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} +} + +func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} +} + +// Request reply for ListInstalledColormaps +// size: (32 + xgb.Pad((int(CmapsLen) * 4))) +type ListInstalledColormapsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CmapsLen uint16 + // padding: 22 bytes + Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) +} + +// Waits and reads reply data from request ListInstalledColormaps +func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInstalledColormapsReply(buf), nil +} + +// Read reply into structure from buffer for ListInstalledColormaps +func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { + v := new(ListInstalledColormapsReply) + 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.CmapsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Cmaps = make([]Colormap, v.CmapsLen) + for i := 0; i < int(v.CmapsLen); i++ { + v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for ListInstalledColormaps +func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 83 // request opcode + b += 1 + + b += 1 // padding + + 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 AllocColor +// size: 16 +type AllocColorCookie struct { + *xgb.Cookie +} + +func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} +} + +func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} +} + +// Request reply for AllocColor +// size: 20 +type AllocColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes + Pixel uint32 +} + +// Waits and reads reply data from request AllocColor +func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorReply(buf), nil +} + +// Read reply into structure from buffer for AllocColor +func allocColorReply(buf []byte) *AllocColorReply { + v := new(AllocColorReply) + 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.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for AllocColor +func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 84 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Red) + b += 2 + + xgb.Put16(buf[b:], Green) + b += 2 + + xgb.Put16(buf[b:], Blue) + b += 2 + + b += 2 // padding + + return buf +} + +// Request AllocNamedColor +// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +type AllocNamedColorCookie struct { + *xgb.Cookie +} + +func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} +} + +func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} +} + +// Request reply for AllocNamedColor +// size: 24 +type AllocNamedColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Pixel uint32 + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 +} + +// Waits and reads reply data from request AllocNamedColor +func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocNamedColorReply(buf), nil +} + +// Read reply into structure from buffer for AllocNamedColor +func allocNamedColorReply(buf []byte) *AllocNamedColorReply { + v := new(AllocNamedColorReply) + 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.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 + + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 + + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 + + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 + + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 + + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for AllocNamedColor +func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 85 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request AllocColorCells +// size: 12 +type AllocColorCellsCookie struct { + *xgb.Cookie +} + +func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} +} + +func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} +} + +// Request reply for AllocColorCells +// size: ((32 + xgb.Pad((int(PixelsLen) * 4))) + xgb.Pad((int(MasksLen) * 4))) +type AllocColorCellsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PixelsLen uint16 + MasksLen uint16 + // padding: 20 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) + Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) +} + +// Waits and reads reply data from request AllocColorCells +func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorCellsReply(buf), nil +} + +// Read reply into structure from buffer for AllocColorCells +func allocColorCellsReply(buf []byte) *AllocColorCellsReply { + v := new(AllocColorCellsReply) + 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.PixelsLen = xgb.Get16(buf[b:]) + b += 2 + + v.MasksLen = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Masks = make([]uint32, v.MasksLen) + for i := 0; i < int(v.MasksLen); i++ { + v.Masks[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for AllocColorCells +func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 86 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Colors) + b += 2 + + xgb.Put16(buf[b:], Planes) + b += 2 + + return buf +} + +// Request AllocColorPlanes +// size: 16 +type AllocColorPlanesCookie struct { + *xgb.Cookie +} + +func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} +} + +func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} +} + +// Request reply for AllocColorPlanes +// size: (32 + xgb.Pad((int(PixelsLen) * 4))) +type AllocColorPlanesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PixelsLen uint16 + // padding: 2 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 8 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) +} + +// Waits and reads reply data from request AllocColorPlanes +func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorPlanesReply(buf), nil +} + +// Read reply into structure from buffer for AllocColorPlanes +func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { + v := new(AllocColorPlanesReply) + 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.PixelsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for AllocColorPlanes +func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 87 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Colors) + b += 2 + + xgb.Put16(buf[b:], Reds) + b += 2 + + xgb.Put16(buf[b:], Greens) + b += 2 + + xgb.Put16(buf[b:], Blues) + b += 2 + + return buf +} + +// Request FreeColors +// size: xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) +type FreeColorsCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeColors +func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} +} + +func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} +} + +func (cook FreeColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColors +func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 88 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put32(buf[b:], PlaneMask) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request StoreColors +// size: xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) +type StoreColorsCookie struct { + *xgb.Cookie +} + +// Write request to wire for StoreColors +func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} + +func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} + +func (cook StoreColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StoreColors +func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 89 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + b += ColoritemListBytes(buf[b:], Items) + + return buf +} + +// Request StoreNamedColor +// size: xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +type StoreNamedColorCookie struct { + *xgb.Cookie +} + +// Write request to wire for StoreNamedColor +func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} +} + +func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} +} + +func (cook StoreNamedColorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StoreNamedColor +func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 90 // request opcode + b += 1 + + buf[b] = Flags + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put32(buf[b:], Pixel) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request QueryColors +// size: xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) +type QueryColorsCookie struct { + *xgb.Cookie +} + +func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +// Request reply for QueryColors +// size: (32 + xgb.Pad((int(ColorsLen) * 8))) +type QueryColorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ColorsLen uint16 + // padding: 22 bytes + Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) +} + +// Waits and reads reply data from request QueryColors +func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryColorsReply(buf), nil +} + +// Read reply into structure from buffer for QueryColors +func queryColorsReply(buf []byte) *QueryColorsReply { + v := new(QueryColorsReply) + 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.ColorsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Colors = make([]Rgb, v.ColorsLen) + b += RgbReadList(buf[b:], v.Colors) + + return v +} + +// Write request to wire for QueryColors +func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 91 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request LookupColor +// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +type LookupColorCookie struct { + *xgb.Cookie +} + +func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} +} + +func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} +} + +// Request reply for LookupColor +// size: 20 +type LookupColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 +} + +// Waits and reads reply data from request LookupColor +func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return lookupColorReply(buf), nil +} + +// Read reply into structure from buffer for LookupColor +func lookupColorReply(buf []byte) *LookupColorReply { + v := new(LookupColorReply) + 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.ExactRed = xgb.Get16(buf[b:]) + b += 2 + + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 + + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 + + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 + + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 + + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for LookupColor +func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 92 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request CreateCursor +// size: 32 +type CreateCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateCursor +func CreateCursor(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func (cook CreateCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCursor +func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 93 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf +} + +// Request CreateGlyphCursor +// size: 32 +type CreateGlyphCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGlyphCursor +func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} +} + +func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} +} + +func (cook CreateGlyphCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGlyphCursor +func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 94 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SourceFont)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFont)) + b += 4 + + xgb.Put16(buf[b:], SourceChar) + b += 2 + + xgb.Put16(buf[b:], MaskChar) + b += 2 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + return buf +} + +// Request FreeCursor +// size: 8 +type FreeCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeCursor +func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +func (cook FreeCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeCursor +func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 95 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + return buf +} + +// Request RecolorCursor +// size: 20 +type RecolorCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for RecolorCursor +func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} +} + +func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} +} + +func (cook RecolorCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RecolorCursor +func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 96 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + return buf +} + +// Request QueryBestSize +// size: 12 +type QueryBestSizeCookie struct { + *xgb.Cookie +} + +func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} +} + +func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} +} + +// Request reply for QueryBestSize +// size: 12 +type QueryBestSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint16 + Height uint16 +} + +// Waits and reads reply data from request QueryBestSize +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryBestSizeReply(buf), nil +} + +// Read reply into structure from buffer for QueryBestSize +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) + 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.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryBestSize +func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 97 // request opcode + b += 1 + + buf[b] = Class + 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:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request QueryExtension +// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +type QueryExtensionCookie struct { + *xgb.Cookie +} + +func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} +} + +func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} +} + +// Request reply for QueryExtension +// size: 12 +type QueryExtensionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte +} + +// Waits and reads reply data from request QueryExtension +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtension +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) + 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.Present = true + } else { + v.Present = false + } + b += 1 + + v.MajorOpcode = buf[b] + b += 1 + + v.FirstEvent = buf[b] + b += 1 + + v.FirstError = buf[b] + b += 1 + + return v +} + +// Write request to wire for QueryExtension +func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 98 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request ListExtensions +// size: 4 +type ListExtensionsCookie struct { + *xgb.Cookie +} + +func ListExtensions(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} +} + +func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} +} + +// Request reply for ListExtensions +// size: (32 + StrListSize(Names)) +type ListExtensionsReply struct { + Sequence uint16 + Length uint32 + NamesLen byte + // padding: 24 bytes + Names []Str // size: StrListSize(Names) +} + +// Waits and reads reply data from request ListExtensions +func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listExtensionsReply(buf), nil +} + +// Read reply into structure from buffer for ListExtensions +func listExtensionsReply(buf []byte) *ListExtensionsReply { + v := new(ListExtensionsReply) + b := 1 // skip reply determinant + + v.NamesLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) + + return v +} + +// Write request to wire for ListExtensions +func listExtensionsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 99 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangeKeyboardMapping +// size: xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +type ChangeKeyboardMappingCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeKeyboardMapping +func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} +} + +func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} +} + +func (cook ChangeKeyboardMappingCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeKeyboardMapping +func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 100 // request opcode + b += 1 + + buf[b] = KeycodeCount + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = KeysymsPerKeycode + b += 1 + + b += 2 // padding + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetKeyboardMapping +// size: 8 +type GetKeyboardMappingCookie struct { + *xgb.Cookie +} + +func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} +} + +func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} +} + +// Request reply for GetKeyboardMapping +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetKeyboardMappingReply struct { + Sequence uint16 + Length uint32 + KeysymsPerKeycode byte + // padding: 24 bytes + Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetKeyboardMapping +func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetKeyboardMapping +func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { + v := new(GetKeyboardMappingReply) + b := 1 // skip reply determinant + + v.KeysymsPerKeycode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keysyms = make([]Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetKeyboardMapping +func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 101 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + + return buf +} + +// Request ChangeKeyboardControl +// size: xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeKeyboardControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeKeyboardControl +func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} + +func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} + +func (cook ChangeKeyboardControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeKeyboardControl +func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 102 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + 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 GetKeyboardControl +// size: 4 +type GetKeyboardControlCookie struct { + *xgb.Cookie +} + +func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +// Request reply for GetKeyboardControl +// size: 52 +type GetKeyboardControlReply struct { + Sequence uint16 + Length uint32 + GlobalAutoRepeat byte + LedMask uint32 + KeyClickPercent byte + BellPercent byte + BellPitch uint16 + BellDuration uint16 + // padding: 2 bytes + AutoRepeats []byte // size: 32 +} + +// Waits and reads reply data from request GetKeyboardControl +func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardControlReply(buf), nil +} + +// Read reply into structure from buffer for GetKeyboardControl +func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant + + v.GlobalAutoRepeat = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.KeyClickPercent = buf[b] + b += 1 + + v.BellPercent = buf[b] + b += 1 + + v.BellPitch = xgb.Get16(buf[b:]) + b += 2 + + v.BellDuration = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for GetKeyboardControl +func getKeyboardControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 103 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request Bell +// size: 4 +type BellCookie struct { + *xgb.Cookie +} + +// Write request to wire for Bell +func Bell(c *xgb.Conn, Percent int8) BellCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} +} + +func BellChecked(c *xgb.Conn, Percent int8) BellCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} +} + +func (cook BellCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Bell +func bellRequest(c *xgb.Conn, Percent int8) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 104 // request opcode + b += 1 + + buf[b] = byte(Percent) + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangePointerControl +// size: 12 +type ChangePointerControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangePointerControl +func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} +} + +func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} +} + +func (cook ChangePointerControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangePointerControl +func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 105 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 + + xgb.Put16(buf[b:], uint16(Threshold)) + b += 2 + + if DoAcceleration { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if DoThreshold { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetPointerControl +// size: 4 +type GetPointerControlCookie struct { + *xgb.Cookie +} + +func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} +} + +func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} +} + +// Request reply for GetPointerControl +// size: 32 +type GetPointerControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + AccelerationNumerator uint16 + AccelerationDenominator uint16 + Threshold uint16 + // padding: 18 bytes +} + +// Waits and reads reply data from request GetPointerControl +func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerControlReply(buf), nil +} + +// Read reply into structure from buffer for GetPointerControl +func getPointerControlReply(buf []byte) *GetPointerControlReply { + v := new(GetPointerControlReply) + 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.AccelerationNumerator = xgb.Get16(buf[b:]) + b += 2 + + v.AccelerationDenominator = xgb.Get16(buf[b:]) + b += 2 + + v.Threshold = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v +} + +// Write request to wire for GetPointerControl +func getPointerControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 106 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetScreenSaver +// size: 12 +type SetScreenSaverCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetScreenSaver +func SetScreenSaver(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) + return SetScreenSaverCookie{cookie} +} + +func SetScreenSaverChecked(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) + return SetScreenSaverCookie{cookie} +} + +func (cook SetScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetScreenSaver +func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 107 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], uint16(Timeout)) + b += 2 + + xgb.Put16(buf[b:], uint16(Interval)) + b += 2 + + buf[b] = PreferBlanking + b += 1 + + buf[b] = AllowExposures + b += 1 + + return buf +} + +// Request GetScreenSaver +// size: 4 +type GetScreenSaverCookie struct { + *xgb.Cookie +} + +func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} +} + +func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} +} + +// Request reply for GetScreenSaver +// size: 32 +type GetScreenSaverReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timeout uint16 + Interval uint16 + PreferBlanking byte + AllowExposures byte + // padding: 18 bytes +} + +// Waits and reads reply data from request GetScreenSaver +func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenSaverReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenSaver +func getScreenSaverReply(buf []byte) *GetScreenSaverReply { + v := new(GetScreenSaverReply) + 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.Timeout = xgb.Get16(buf[b:]) + b += 2 + + v.Interval = xgb.Get16(buf[b:]) + b += 2 + + v.PreferBlanking = buf[b] + b += 1 + + v.AllowExposures = buf[b] + b += 1 + + b += 18 // padding + + return v +} + +// Write request to wire for GetScreenSaver +func getScreenSaverRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 108 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangeHosts +// size: xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) +type ChangeHostsCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeHosts +func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} +} + +func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} +} + +func (cook ChangeHostsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeHosts +func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 109 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Family + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], AddressLen) + b += 2 + + copy(buf[b:], Address[:AddressLen]) + b += xgb.Pad(int(AddressLen)) + + return buf +} + +// Request ListHosts +// size: 4 +type ListHostsCookie struct { + *xgb.Cookie +} + +func ListHosts(c *xgb.Conn) ListHostsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} +} + +func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} +} + +// Request reply for ListHosts +// size: (32 + HostListSize(Hosts)) +type ListHostsReply struct { + Sequence uint16 + Length uint32 + Mode byte + HostsLen uint16 + // padding: 22 bytes + Hosts []Host // size: HostListSize(Hosts) +} + +// Waits and reads reply data from request ListHosts +func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listHostsReply(buf), nil +} + +// Read reply into structure from buffer for ListHosts +func listHostsReply(buf []byte) *ListHostsReply { + v := new(ListHostsReply) + b := 1 // skip reply determinant + + v.Mode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.HostsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Hosts = make([]Host, v.HostsLen) + b += HostReadList(buf[b:], v.Hosts) + + return v +} + +// Write request to wire for ListHosts +func listHostsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 110 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetAccessControl +// size: 4 +type SetAccessControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetAccessControl +func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} +} + +func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} +} + +func (cook SetAccessControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetAccessControl +func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 111 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetCloseDownMode +// size: 4 +type SetCloseDownModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCloseDownMode +func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} +} + +func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} +} + +func (cook SetCloseDownModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCloseDownMode +func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 112 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request KillClient +// size: 8 +type KillClientCookie struct { + *xgb.Cookie +} + +// Write request to wire for KillClient +func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} +} + +func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} +} + +func (cook KillClientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for KillClient +func killClientRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 113 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Resource) + b += 4 + + return buf +} + +// Request RotateProperties +// size: xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) +type RotatePropertiesCookie struct { + *xgb.Cookie +} + +// Write request to wire for RotateProperties +func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} +} + +func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} +} + +func (cook RotatePropertiesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RotateProperties +func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { + size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 114 // request opcode + b += 1 + + b += 1 // padding + + 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.Put16(buf[b:], AtomsLen) + b += 2 + + xgb.Put16(buf[b:], uint16(Delta)) + b += 2 + + for i := 0; i < int(AtomsLen); i++ { + xgb.Put32(buf[b:], uint32(Atoms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ForceScreenSaver +// size: 4 +type ForceScreenSaverCookie struct { + *xgb.Cookie +} + +// Write request to wire for ForceScreenSaver +func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +func (cook ForceScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ForceScreenSaver +func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 115 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetPointerMapping +// size: xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) +type SetPointerMappingCookie struct { + *xgb.Cookie +} + +func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} +} + +func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} +} + +// Request reply for SetPointerMapping +// size: 8 +type SetPointerMappingReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request SetPointerMapping +func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setPointerMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetPointerMapping +func setPointerMappingReply(buf []byte) *SetPointerMappingReply { + v := new(SetPointerMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + 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 SetPointerMapping +func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { + size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 116 // request opcode + b += 1 + + buf[b] = MapLen + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + copy(buf[b:], Map[:MapLen]) + b += xgb.Pad(int(MapLen)) + + return buf +} + +// Request GetPointerMapping +// size: 4 +type GetPointerMappingCookie struct { + *xgb.Cookie +} + +func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} +} + +func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} +} + +// Request reply for GetPointerMapping +// size: (32 + xgb.Pad((int(MapLen) * 1))) +type GetPointerMappingReply struct { + Sequence uint16 + Length uint32 + MapLen byte + // padding: 24 bytes + Map []byte // size: xgb.Pad((int(MapLen) * 1)) +} + +// Waits and reads reply data from request GetPointerMapping +func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetPointerMapping +func getPointerMappingReply(buf []byte) *GetPointerMappingReply { + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant + + v.MapLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Map = make([]byte, v.MapLen) + copy(v.Map[:v.MapLen], buf[b:]) + b += xgb.Pad(int(v.MapLen)) + + return v +} + +// Write request to wire for GetPointerMapping +func getPointerMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 117 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetModifierMapping +// size: xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +type SetModifierMappingCookie struct { + *xgb.Cookie +} + +func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} +} + +func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} +} + +// Request reply for SetModifierMapping +// size: 8 +type SetModifierMappingReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request SetModifierMapping +func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetModifierMapping +func setModifierMappingReply(buf []byte) *SetModifierMappingReply { + v := new(SetModifierMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + 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 SetModifierMapping +func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { + size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 118 // request opcode + b += 1 + + buf[b] = KeycodesPerModifier + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { + buf[b] = byte(Keycodes[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetModifierMapping +// size: 4 +type GetModifierMappingCookie struct { + *xgb.Cookie +} + +func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} +} + +func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} +} + +// Request reply for GetModifierMapping +// size: (32 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1))) +type GetModifierMappingReply struct { + Sequence uint16 + Length uint32 + KeycodesPerModifier byte + // padding: 24 bytes + Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +} + +// Waits and reads reply data from request GetModifierMapping +func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetModifierMapping +func getModifierMappingReply(buf []byte) *GetModifierMappingReply { + v := new(GetModifierMappingReply) + b := 1 // skip reply determinant + + v.KeycodesPerModifier = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) + for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { + v.Keycodes[i] = Keycode(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetModifierMapping +func getModifierMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 119 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request NoOperation +// size: 4 +type NoOperationCookie struct { + *xgb.Cookie +} + +// Write request to wire for NoOperation +func NoOperation(c *xgb.Conn) NoOperationCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} +} + +func NoOperationChecked(c *xgb.Conn) NoOperationCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} +} + +func (cook NoOperationCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for NoOperation +func noOperationRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 127 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/xproto/xproto_test.go b/nexgb/xproto/xproto_test.go new file mode 100644 index 0000000..f061198 --- /dev/null +++ b/nexgb/xproto/xproto_test.go @@ -0,0 +1,365 @@ +package xproto + +/* + Tests for XGB. + + These tests only test the core X protocol at the moment. It isn't even + close to complete coverage (and probably never will be), but it does test + a number of different corners: requests with no replies, requests without + replies, checked (i.e., synchronous) errors, unchecked (i.e., asynchronous) + errors, and sequence number wrapping. + + There are also a couple of benchmarks that show the difference between + correctly issuing lots of requests and gathering replies and + incorrectly doing the same. (This particular difference is one of the + claimed advantages of the XCB, and therefore XGB, family. +*/ + +import ( + "fmt" + "log" + "math/rand" + "testing" + "time" + + "github.com/BurntSushi/xgb" +) + +// The X connection used throughout testing. +var X *xgb.Conn + +// init initializes the X connection, seeds the RNG and starts waiting +// for events. +func init() { + var err error + + X, err = xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + rand.Seed(time.Now().UnixNano()) + + go grabEvents() +} + +/******************************************************************************/ +// Tests +/******************************************************************************/ + +// TestSynchronousError purposefully causes a BadWindow error in a +// MapWindow request, and checks it synchronously. +func TestSynchronousError(t *testing.T) { + 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.") + } + verifyMapWindowError(t, err) +} + +// TestAsynchronousError does the same thing as TestSynchronousError, but +// grabs the error asynchronously instead. +func TestAsynchronousError(t *testing.T) { + MapWindow(X, 0) // resource id 0 is always invalid + + evOrErr := waitForEvent(t, 5) + if evOrErr.ev != nil { + t.Fatalf("After issuing an erroneous MapWindow request, we have "+ + "received an event rather than an error: %s", evOrErr.ev) + } + verifyMapWindowError(t, evOrErr.err) +} + +// TestCookieBuffer issues (2^16) + n requets *without* replies to guarantee +// that the sequence number wraps and that the cookie buffer will have to +// flush itself (since there are no replies coming in to flush it). +// And just like TestSequenceWrap, we issue another request with a reply +// at the end to make sure XGB is still working properly. +func TestCookieBuffer(t *testing.T) { + n := (1 << 16) + 10 + for i := 0; i < n; i++ { + NoOperation(X) + } + TestProperty(t) +} + +// TestSequenceWrap issues (2^16) + n requests w/ replies to guarantee that the +// sequence number (which is a 16 bit integer) will wrap. It then issues one +// final request to ensure things still work properly. +func TestSequenceWrap(t *testing.T) { + n := (1 << 16) + 10 + for i := 0; i < n; i++ { + _, err := InternAtom(X, false, 5, "RANDO").Reply() + if err != nil { + t.Fatalf("InternAtom: %s", err) + } + } + TestProperty(t) +} + +// TestProperty tests whether a random value can be set and read. +func TestProperty(t *testing.T) { + propName := randString(20) // whatevs + writeVal := randString(20) + readVal, err := changeAndGetProp(propName, writeVal) + if err != nil { + t.Error(err) + } + + if readVal != writeVal { + t.Errorf("The value written, '%s', is not the same as the "+ + "value read '%s'.", writeVal, readVal) + } +} + +// TestWindowEvents creates a window, maps it, listens for configure notify +// events, issues a configure request, and checks for the appropriate +// configure notify event. +// This probably violates the notion of "test one thing and test it well," +// but testing X stuff is unique since it involves so much state. +// Each request is checked to make sure there are no errors returned. If there +// is an error, the test is failed. +// You may see a window appear quickly and then disappear. Do not be alarmed :P +// It's possible that this test will yield a false negative because we cannot +// control our environment. That is, the window manager could override the +// placement set. However, we set override redirect on the window, so the +// window manager *shouldn't* touch our window if it is well-behaved. +func TestWindowEvents(t *testing.T) { + // The geometry to set the window. + gx, gy, gw, gh := 200, 400, 1000, 300 + + wid, err := NewWindowId(X) + if err != nil { + t.Fatalf("NewId: %s", err) + } + + 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() + if err != nil { + t.Fatalf("CreateWindow: %s", err) + } + + 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 = ChangeWindowAttributesChecked(X, wid, + CwEventMask, []uint32{EventMaskStructureNotify}).Check() + if err != nil { + t.Fatalf("ChangeWindowAttributes: %s", err) + } + + err = ConfigureWindowChecked(X, wid, + ConfigWindowX|ConfigWindowY| + ConfigWindowWidth|ConfigWindowHeight, + []uint32{uint32(gx), uint32(gy), uint32(gw), uint32(gh)}).Check() + if err != nil { + t.Fatalf("ConfigureWindow: %s", err) + } + + TestProperty(t) + + evOrErr := waitForEvent(t, 5) + switch event := evOrErr.ev.(type) { + case ConfigureNotifyEvent: + if event.X != int16(gx) { + t.Fatalf("x was set to %d but ConfigureNotify reports %d", + gx, event.X) + } + if event.Y != int16(gy) { + t.Fatalf("y was set to %d but ConfigureNotify reports %d", + gy, event.Y) + } + if event.Width != uint16(gw) { + t.Fatalf("width was set to %d but ConfigureNotify reports %d", + gw, event.Width) + } + if event.Height != uint16(gh) { + t.Fatalf("height was set to %d but ConfigureNotify reports %d", + gh, event.Height) + } + default: + t.Fatalf("Expected a ConfigureNotifyEvent but got %T instead.", event) + } + + // Okay, clean up! + err = ChangeWindowAttributesChecked(X, wid, + CwEventMask, []uint32{0}).Check() + if err != nil { + t.Fatalf("ChangeWindowAttributes: %s", err) + } + + err = DestroyWindowChecked(X, wid).Check() + if err != nil { + t.Fatalf("DestroyWindow: %s", err) + } +} + +/******************************************************************************/ +// Benchmarks +/******************************************************************************/ + +// BenchmarkInternAtomsGood shows how many requests with replies +// *should* be sent and gathered from the server. Namely, send as many +// requests as you can at once, then go back and gather up all the replies. +// More importantly, this approach can exploit parallelism when +// GOMAXPROCS > 1. +// Run with `go test -run 'nomatch' -bench '.*' -cpu 1,2,6` if you have +// multiple cores to see the improvement that parallelism brings. +func BenchmarkInternAtomsGood(b *testing.B) { + b.StopTimer() + names := seqNames(b.N) + + b.StartTimer() + cookies := make([]InternAtomCookie, b.N) + for i := 0; i < b.N; i++ { + cookies[i] = InternAtom(X, false, uint16(len(names[i])), names[i]) + } + for _, cookie := range cookies { + cookie.Reply() + } +} + +// BenchmarkInternAtomsBad shows how *not* to issue a lot of requests with +// replies. Namely, each subsequent request isn't issued *until* the last +// reply is made. This implies a round trip to the X server for every +// iteration. +func BenchmarkInternAtomsPoor(b *testing.B) { + b.StopTimer() + names := seqNames(b.N) + + b.StartTimer() + for i := 0; i < b.N; i++ { + InternAtom(X, false, uint16(len(names[i])), names[i]).Reply() + } +} + +/******************************************************************************/ +// Helper functions +/******************************************************************************/ + +// changeAndGetProp sets property 'prop' with value 'val'. +// It then gets the value of that property and returns it. +// (It's used to check that the 'val' going in is the same 'val' going out.) +// It tests both requests with and without replies (GetProperty and +// ChangeProperty respectively.) +func changeAndGetProp(prop, val string) (string, error) { + 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 := InternAtom(X, false, uint16(len(typName)), typName).Reply() + if err != nil { + return "", fmt.Errorf("InternAtom: %s", err) + } + + 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 := GetProperty(X, false, root, propAtom.Atom, + GetPropertyTypeAny, 0, (1<<32)-1).Reply() + if err != nil { + return "", fmt.Errorf("GetProperty: %s", err) + } + if reply.Format != 8 { + return "", fmt.Errorf("Property reply format is %d but it should be 8.", + reply.Format) + } + + return string(reply.Value), nil +} + +// verifyMapWindowError takes an error that is returned with an invalid +// MapWindow request with a window Id of 0 and makes sure the error is the +// right type and contains the correct values. +func verifyMapWindowError(t *testing.T, err error) { + switch e := err.(type) { + case WindowError: + if e.BadValue != 0 { + t.Fatalf("WindowError should report a bad value of 0 but "+ + "it reports %d instead.", e.BadValue) + } + if e.MajorOpcode != 8 { + t.Fatalf("WindowError should report a major opcode of 8 "+ + "(which is a MapWindow request), but it reports %d instead.", + e.MajorOpcode) + } + default: + t.Fatalf("Expected a WindowError but got %T instead.", e) + } +} + +// randString generates a random string of length n. +func randString(n int) string { + byts := make([]byte, n) + for i := 0; i < n; i++ { + rando := rand.Intn(53) + switch { + case rando <= 25: + byts[i] = byte(65 + rando) + case rando <= 51: + byts[i] = byte(97 + rando - 26) + default: + byts[i] = ' ' + } + } + return string(byts) +} + +// seqNames creates a slice of NAME0, NAME1, ..., NAMEN. +func seqNames(n int) []string { + names := make([]string, n) + for i := range names { + names[i] = fmt.Sprintf("NAME%d", i) + } + return names +} + +// evErr represents a value that is either an event or an error. +type evErr struct { + ev xgb.Event + err xgb.Error +} + +// channel used to pass evErrs. +var evOrErrChan = make(chan evErr, 0) + +// grabEvents is a goroutine that reads events off the wire. +// We used this instead of WaitForEvent directly in our tests so that +// we can timeout and fail a test. +func grabEvents() { + for { + ev, err := X.WaitForEvent() + evOrErrChan <- evErr{ev, err} + } +} + +// waitForEvent asks the evOrErrChan channel for an event. +// If it doesn't get an event in 'n' seconds, the current test is failed. +func waitForEvent(t *testing.T, n int) evErr { + var evOrErr evErr + + select { + case evOrErr = <-evOrErrChan: + case <-time.After(time.Second * 5): + t.Fatalf("After waiting 5 seconds for an event or an error, " + + "we have timed out.") + } + + return evOrErr +} diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go new file mode 100644 index 0000000..4675e90 --- /dev/null +++ b/nexgb/xselinux/xselinux.go @@ -0,0 +1,1903 @@ +package xselinux + +/* + This file was generated by xselinux.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 SELinux extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 7, "SELinux").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named SELinux could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["SELinux"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["SELinux"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["SELinux"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["SELinux"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["SELinux"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// 'ListItem' struct definition +// Size: ((12 + xgb.Pad((int(ObjectContextLen) * 1))) + xgb.Pad((int(DataContextLen) * 1))) +type ListItem struct { + Name xproto.Atom + ObjectContextLen uint32 + DataContextLen uint32 + ObjectContext string // size: xgb.Pad((int(ObjectContextLen) * 1)) + DataContext string // size: xgb.Pad((int(DataContextLen) * 1)) +} + +// Struct read ListItem +func ListItemRead(buf []byte, v *ListItem) int { + b := 0 + + v.Name = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.ObjectContextLen = xgb.Get32(buf[b:]) + b += 4 + + v.DataContextLen = xgb.Get32(buf[b:]) + b += 4 + + { + byteString := make([]byte, v.ObjectContextLen) + copy(byteString[:v.ObjectContextLen], buf[b:]) + v.ObjectContext = string(byteString) + b += xgb.Pad(int(v.ObjectContextLen)) + } + + { + byteString := make([]byte, v.DataContextLen) + copy(byteString[:v.DataContextLen], buf[b:]) + v.DataContext = string(byteString) + b += xgb.Pad(int(v.DataContextLen)) + } + + return b +} + +// Struct list read ListItem +func ListItemReadList(buf []byte, dest []ListItem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ListItem{} + b += ListItemRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ListItem +func (v ListItem) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + xgb.Pad((int(v.DataContextLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + xgb.Put32(buf[b:], v.ObjectContextLen) + b += 4 + + xgb.Put32(buf[b:], v.DataContextLen) + b += 4 + + copy(buf[b:], v.ObjectContext[:v.ObjectContextLen]) + b += xgb.Pad(int(v.ObjectContextLen)) + + copy(buf[b:], v.DataContext[:v.DataContextLen]) + b += xgb.Pad(int(v.DataContextLen)) + + return buf +} + +// Write struct list ListItem +func ListItemListBytes(buf []byte, list []ListItem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ListItem +func ListItemListSize(list []ListItem) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.ObjectContextLen) * 1))) + xgb.Pad((int(item.DataContextLen) * 1))) + } + return size +} + +// 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["SELINUX"] + 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 SetDeviceCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDeviceCreateContext +func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} + +func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} + +func (cook SetDeviceCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceCreateContext +func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetDeviceCreateContext +// size: 4 +type GetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} +} + +func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} +} + +// Request reply for GetDeviceCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetDeviceCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetDeviceCreateContext +func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceCreateContext +func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { + v := new(GetDeviceCreateContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetDeviceCreateContext +func getDeviceCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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 SetDeviceContext +// size: xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) +type SetDeviceContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDeviceContext +func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +func (cook SetDeviceContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceContext +func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], Device) + b += 4 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetDeviceContext +// size: 8 +type GetDeviceContextCookie struct { + *xgb.Cookie +} + +func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{cookie} +} + +func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{cookie} +} + +// Request reply for GetDeviceContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetDeviceContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetDeviceContext +func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceContextReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceContext +func getDeviceContextReply(buf []byte) *GetDeviceContextReply { + v := new(GetDeviceContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetDeviceContext +func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], Device) + b += 4 + + return buf +} + +// Request SetWindowCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetWindowCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetWindowCreateContext +func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +func (cook SetWindowCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowCreateContext +func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetWindowCreateContext +// size: 4 +type GetWindowCreateContextCookie struct { + *xgb.Cookie +} + +func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} +} + +func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} +} + +// Request reply for GetWindowCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetWindowCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetWindowCreateContext +func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetWindowCreateContext +func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { + v := new(GetWindowCreateContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetWindowCreateContext +func getWindowCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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 + + return buf +} + +// Request GetWindowContext +// size: 8 +type GetWindowContextCookie struct { + *xgb.Cookie +} + +func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} +} + +func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} +} + +// Request reply for GetWindowContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetWindowContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetWindowContext +func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowContextReply(buf), nil +} + +// Read reply into structure from buffer for GetWindowContext +func getWindowContextReply(buf []byte) *GetWindowContextReply { + v := new(GetWindowContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetWindowContext +func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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 SetPropertyCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetPropertyCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPropertyCreateContext +func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +func (cook SetPropertyCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyCreateContext +func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetPropertyCreateContext +// size: 4 +type GetPropertyCreateContextCookie struct { + *xgb.Cookie +} + +func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} +} + +func GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} +} + +// Request reply for GetPropertyCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyCreateContext +func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyCreateContext +func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { + v := new(GetPropertyCreateContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyCreateContext +func getPropertyCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetPropertyUseContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetPropertyUseContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPropertyUseContext +func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +func (cook SetPropertyUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyUseContext +func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetPropertyUseContext +// size: 4 +type GetPropertyUseContextCookie struct { + *xgb.Cookie +} + +func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} +} + +func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} +} + +// Request reply for GetPropertyUseContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyUseContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyUseContext +func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyUseContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyUseContext +func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { + v := new(GetPropertyUseContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyUseContext +func getPropertyUseContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetPropertyContext +// size: 12 +type GetPropertyContextCookie struct { + *xgb.Cookie +} + +func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} +} + +func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} +} + +// Request reply for GetPropertyContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyContext +func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyContext +func getPropertyContextReply(buf []byte) *GetPropertyContextReply { + v := new(GetPropertyContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyContext +func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request GetPropertyDataContext +// size: 12 +type GetPropertyDataContextCookie struct { + *xgb.Cookie +} + +func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} +} + +func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} +} + +// Request reply for GetPropertyDataContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyDataContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyDataContext +func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyDataContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyDataContext +func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { + v := new(GetPropertyDataContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyDataContext +func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request ListProperties +// size: 8 +type ListPropertiesCookie struct { + *xgb.Cookie +} + +func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +// Request reply for ListProperties +// size: (32 + ListItemListSize(Properties)) +type ListPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PropertiesLen uint32 + // padding: 20 bytes + Properties []ListItem // size: ListItemListSize(Properties) +} + +// Waits and reads reply data from request ListProperties +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listPropertiesReply(buf), nil +} + +// Read reply into structure from buffer for ListProperties +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) + 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.PropertiesLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Properties = make([]ListItem, v.PropertiesLen) + b += ListItemReadList(buf[b:], v.Properties) + + return v +} + +// Write request to wire for ListProperties +func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetSelectionCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetSelectionCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetSelectionCreateContext +func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +func (cook SetSelectionCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionCreateContext +func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetSelectionCreateContext +// size: 4 +type GetSelectionCreateContextCookie struct { + *xgb.Cookie +} + +func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} +} + +func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} +} + +// Request reply for GetSelectionCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionCreateContext +func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionCreateContext +func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { + v := new(GetSelectionCreateContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionCreateContext +func getSelectionCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetSelectionUseContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetSelectionUseContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetSelectionUseContext +func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +func (cook SetSelectionUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionUseContext +func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetSelectionUseContext +// size: 4 +type GetSelectionUseContextCookie struct { + *xgb.Cookie +} + +func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} +} + +func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} +} + +// Request reply for GetSelectionUseContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionUseContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionUseContext +func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionUseContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionUseContext +func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { + v := new(GetSelectionUseContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionUseContext +func getSelectionUseContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetSelectionContext +// size: 8 +type GetSelectionContextCookie struct { + *xgb.Cookie +} + +func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} +} + +func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} +} + +// Request reply for GetSelectionContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionContext +func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionContext +func getSelectionContextReply(buf []byte) *GetSelectionContextReply { + v := new(GetSelectionContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionContext +func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + +// Request GetSelectionDataContext +// size: 8 +type GetSelectionDataContextCookie struct { + *xgb.Cookie +} + +func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} +} + +func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} +} + +// Request reply for GetSelectionDataContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionDataContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionDataContext +func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionDataContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionDataContext +func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { + v := new(GetSelectionDataContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionDataContext +func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + +// Request ListSelections +// size: 4 +type ListSelectionsCookie struct { + *xgb.Cookie +} + +func ListSelections(c *xgb.Conn) ListSelectionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} +} + +func ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} +} + +// Request reply for ListSelections +// size: (32 + ListItemListSize(Selections)) +type ListSelectionsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SelectionsLen uint32 + // padding: 20 bytes + Selections []ListItem // size: ListItemListSize(Selections) +} + +// Waits and reads reply data from request ListSelections +func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSelectionsReply(buf), nil +} + +// Read reply into structure from buffer for ListSelections +func listSelectionsReply(buf []byte) *ListSelectionsReply { + v := new(ListSelectionsReply) + 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.SelectionsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Selections = make([]ListItem, v.SelectionsLen) + b += ListItemReadList(buf[b:], v.Selections) + + return v +} + +// Write request to wire for ListSelections +func listSelectionsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetClientContext +// size: 8 +type GetClientContextCookie struct { + *xgb.Cookie +} + +func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} +} + +func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} +} + +// Request reply for GetClientContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetClientContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetClientContext +func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClientContextReply(buf), nil +} + +// Read reply into structure from buffer for GetClientContext +func getClientContextReply(buf []byte) *GetClientContextReply { + v := new(GetClientContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetClientContext +func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Resource) + b += 4 + + return buf +} diff --git a/nexgb/xtest/xtest.go b/nexgb/xtest/xtest.go new file mode 100644 index 0000000..e035fe5 --- /dev/null +++ b/nexgb/xtest/xtest.go @@ -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 +} diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go new file mode 100644 index 0000000..8faaf83 --- /dev/null +++ b/nexgb/xv/xv.go @@ -0,0 +1,2746 @@ +package xv + +/* + This file was generated by xv.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/shm" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XVideo extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "XVideo").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XVideo could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XVideo"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XVideo"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XVideo"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XVideo"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XVideo"] = 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 ( + TypeInputMask = 1 + TypeOutputMask = 2 + TypeVideoMask = 4 + TypeStillMask = 8 + TypeImageMask = 16 +) + +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) + +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) + +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +const ( + VideoNotifyReasonStarted = 0 + VideoNotifyReasonStopped = 1 + VideoNotifyReasonBusy = 2 + VideoNotifyReasonPreempted = 3 + VideoNotifyReasonHardError = 4 +) + +const ( + ScanlineOrderTopToBottom = 0 + ScanlineOrderBottomToTop = 1 +) + +const ( + GrabPortStatusSuccess = 0 + GrabPortStatusBadExtension = 1 + GrabPortStatusAlreadyGrabbed = 2 + GrabPortStatusInvalidTime = 3 + GrabPortStatusBadReply = 4 + GrabPortStatusBadAlloc = 5 +) + +type Port uint32 + +func NewPortId(c *xgb.Conn) (Port, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Port(id), nil +} + +type Encoding uint32 + +func NewEncodingId(c *xgb.Conn) (Encoding, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Encoding(id), nil +} + +// 'Rational' struct definition +// Size: 8 +type Rational struct { + Numerator int32 + Denominator int32 +} + +// Struct read Rational +func RationalRead(buf []byte, v *Rational) int { + b := 0 + + v.Numerator = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Denominator = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Rational +func RationalReadList(buf []byte, dest []Rational) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rational{} + b += RationalRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rational +func (v Rational) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Numerator)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Denominator)) + b += 4 + + return buf +} + +// Write struct list Rational +func RationalListBytes(buf []byte, list []Rational) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Format' struct definition +// Size: 8 +type Format struct { + Visual xproto.Visualid + Depth byte + // padding: 3 bytes +} + +// Struct read Format +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read Format +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Format +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list Format +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AdaptorInfo' struct definition +// Size: ((12 + xgb.Pad((int(NameSize) * 1))) + xgb.Pad((int(NumFormats) * 8))) +type AdaptorInfo struct { + BaseId Port + NameSize uint16 + NumPorts uint16 + NumFormats uint16 + Type byte + // padding: 1 bytes + Name string // size: xgb.Pad((int(NameSize) * 1)) + Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) +} + +// Struct read AdaptorInfo +func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { + b := 0 + + v.BaseId = Port(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.NumPorts = xgb.Get16(buf[b:]) + b += 2 + + v.NumFormats = xgb.Get16(buf[b:]) + b += 2 + + v.Type = buf[b] + b += 1 + + b += 1 // padding + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + v.Formats = make([]Format, v.NumFormats) + b += FormatReadList(buf[b:], v.Formats) + + return b +} + +// Struct list read AdaptorInfo +func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AdaptorInfo{} + b += AdaptorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AdaptorInfo +func (v AdaptorInfo) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.BaseId)) + b += 4 + + xgb.Put16(buf[b:], v.NameSize) + b += 2 + + xgb.Put16(buf[b:], v.NumPorts) + b += 2 + + xgb.Put16(buf[b:], v.NumFormats) + b += 2 + + buf[b] = v.Type + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) + + b += FormatListBytes(buf[b:], v.Formats) + + return buf +} + +// Write struct list AdaptorInfo +func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size AdaptorInfo +func AdaptorInfoListSize(list []AdaptorInfo) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.NameSize) * 1))) + xgb.Pad((int(item.NumFormats) * 8))) + } + return size +} + +// 'EncodingInfo' struct definition +// Size: (20 + xgb.Pad((int(NameSize) * 1))) +type EncodingInfo struct { + Encoding Encoding + NameSize uint16 + Width uint16 + Height uint16 + // padding: 2 bytes + Rate Rational + Name string // size: xgb.Pad((int(NameSize) * 1)) +} + +// Struct read EncodingInfo +func EncodingInfoRead(buf []byte, v *EncodingInfo) int { + b := 0 + + v.Encoding = Encoding(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Rate = Rational{} + b += RationalRead(buf[b:], &v.Rate) + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + return b +} + +// Struct list read EncodingInfo +func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = EncodingInfo{} + b += EncodingInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write EncodingInfo +func (v EncodingInfo) Bytes() []byte { + buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Encoding)) + b += 4 + + xgb.Put16(buf[b:], v.NameSize) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + b += 2 // padding + + { + structBytes := v.Rate.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) + + return buf +} + +// Write struct list EncodingInfo +func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size EncodingInfo +func EncodingInfoListSize(list []EncodingInfo) int { + size := 0 + for _, item := range list { + size += (20 + xgb.Pad((int(item.NameSize) * 1))) + } + return size +} + +// 'Image' struct definition +// Size: (((16 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(DataSize) * 1))) +type Image struct { + Id uint32 + Width uint16 + Height uint16 + DataSize uint32 + NumPlanes uint32 + Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Data []byte // size: xgb.Pad((int(DataSize) * 1)) +} + +// Struct read Image +func ImageRead(buf []byte, v *Image) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.DataSize = xgb.Get32(buf[b:]) + b += 4 + + v.NumPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.Pitches = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Pitches[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Offsets = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Offsets[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Data = make([]byte, v.DataSize) + copy(v.Data[:v.DataSize], buf[b:]) + b += xgb.Pad(int(v.DataSize)) + + return b +} + +// Struct list read Image +func ImageReadList(buf []byte, dest []Image) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Image{} + b += ImageRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Image +func (v Image) Bytes() []byte { + buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put32(buf[b:], v.DataSize) + b += 4 + + xgb.Put32(buf[b:], v.NumPlanes) + b += 4 + + for i := 0; i < int(v.NumPlanes); i++ { + xgb.Put32(buf[b:], v.Pitches[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumPlanes); i++ { + xgb.Put32(buf[b:], v.Offsets[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], v.Data[:v.DataSize]) + b += xgb.Pad(int(v.DataSize)) + + return buf +} + +// Write struct list Image +func ImageListBytes(buf []byte, list []Image) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Image +func ImageListSize(list []Image) int { + size := 0 + for _, item := range list { + size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) + } + return size +} + +// 'AttributeInfo' struct definition +// Size: (16 + xgb.Pad((int(Size) * 1))) +type AttributeInfo struct { + Flags uint32 + Min int32 + Max int32 + Size uint32 + Name string // size: xgb.Pad((int(Size) * 1)) +} + +// Struct read AttributeInfo +func AttributeInfoRead(buf []byte, v *AttributeInfo) int { + b := 0 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + v.Min = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Max = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Size = xgb.Get32(buf[b:]) + b += 4 + + { + byteString := make([]byte, v.Size) + copy(byteString[:v.Size], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Size)) + } + + return b +} + +// Struct list read AttributeInfo +func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AttributeInfo{} + b += AttributeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AttributeInfo +func (v AttributeInfo) Bytes() []byte { + buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Min)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Max)) + b += 4 + + xgb.Put32(buf[b:], v.Size) + b += 4 + + copy(buf[b:], v.Name[:v.Size]) + b += xgb.Pad(int(v.Size)) + + return buf +} + +// Write struct list AttributeInfo +func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size AttributeInfo +func AttributeInfoListSize(list []AttributeInfo) int { + size := 0 + for _, item := range list { + size += (16 + xgb.Pad((int(item.Size) * 1))) + } + return size +} + +// 'ImageFormatInfo' struct definition +// Size: 128 +type ImageFormatInfo struct { + Id uint32 + Type byte + ByteOrder byte + // padding: 2 bytes + Guid []byte // size: 16 + Bpp byte + NumPlanes byte + // padding: 2 bytes + Depth byte + // padding: 3 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + Format byte + // padding: 3 bytes + YSampleBits uint32 + USampleBits uint32 + VSampleBits uint32 + VhorzYPeriod uint32 + VhorzUPeriod uint32 + VhorzVPeriod uint32 + VvertYPeriod uint32 + VvertUPeriod uint32 + VvertVPeriod uint32 + VcompOrder []byte // size: 32 + VscanlineOrder byte + // padding: 11 bytes +} + +// Struct read ImageFormatInfo +func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Type = buf[b] + b += 1 + + v.ByteOrder = buf[b] + b += 1 + + b += 2 // padding + + v.Guid = make([]byte, 16) + copy(v.Guid[:16], buf[b:]) + b += xgb.Pad(int(16)) + + v.Bpp = buf[b] + b += 1 + + v.NumPlanes = buf[b] + b += 1 + + b += 2 // padding + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + v.Format = buf[b] + b += 1 + + b += 3 // padding + + v.YSampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.USampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.VSampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzYPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzUPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzVPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertYPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertUPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertVPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VcompOrder = make([]byte, 32) + copy(v.VcompOrder[:32], buf[b:]) + b += xgb.Pad(int(32)) + + v.VscanlineOrder = buf[b] + b += 1 + + b += 11 // padding + + return b +} + +// Struct list read ImageFormatInfo +func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ImageFormatInfo{} + b += ImageFormatInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ImageFormatInfo +func (v ImageFormatInfo) Bytes() []byte { + buf := make([]byte, 128) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + buf[b] = v.Type + b += 1 + + buf[b] = v.ByteOrder + b += 1 + + b += 2 // padding + + copy(buf[b:], v.Guid[:16]) + b += xgb.Pad(int(16)) + + buf[b] = v.Bpp + b += 1 + + buf[b] = v.NumPlanes + b += 1 + + b += 2 // padding + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + buf[b] = v.Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], v.YSampleBits) + b += 4 + + xgb.Put32(buf[b:], v.USampleBits) + b += 4 + + xgb.Put32(buf[b:], v.VSampleBits) + b += 4 + + xgb.Put32(buf[b:], v.VhorzYPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VhorzUPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VhorzVPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertYPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertUPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertVPeriod) + b += 4 + + copy(buf[b:], v.VcompOrder[:32]) + b += xgb.Pad(int(32)) + + buf[b] = v.VscanlineOrder + b += 1 + + b += 11 // padding + + return buf +} + +// Write struct list ImageFormatInfo +func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ImageFormatInfo +func ImageFormatInfoListSize(list []ImageFormatInfo) int { + size := 0 + for _ = range list { + size += 128 + } + return size +} + +// Event definition VideoNotify (0) +// Size: 32 + +const VideoNotify = 0 + +type VideoNotifyEvent struct { + Sequence uint16 + Reason byte + Time xproto.Timestamp + Drawable xproto.Drawable + Port Port +} + +// Event read VideoNotify +func VideoNotifyEventNew(buf []byte) xgb.Event { + v := VideoNotifyEvent{} + b := 1 // don't read event number + + v.Reason = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write VideoNotify +func (v VideoNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Reason + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + return buf +} + +func (v VideoNotifyEvent) ImplementsEvent() {} + +func (v VideoNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v VideoNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +} + +// Event definition PortNotify (1) +// Size: 32 + +const PortNotify = 1 + +type PortNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time xproto.Timestamp + Port Port + Attribute xproto.Atom + Value int32 +} + +// Event read PortNotify +func PortNotifyEventNew(buf []byte) xgb.Event { + v := PortNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + + v.Attribute = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write PortNotify +func (v PortNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Value)) + b += 4 + + return buf +} + +func (v PortNotifyEvent) ImplementsEvent() {} + +func (v PortNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PortNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + fieldVals = append(fieldVals, xgb.Sprintf("Attribute: %d", v.Attribute)) + fieldVals = append(fieldVals, xgb.Sprintf("Value: %d", v.Value)) + return "PortNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew +} + +// Error definition BadPort (0) +// Size: 32 + +const BadBadPort = 0 + +type BadPortError struct { + Sequence uint16 + NiceName string +} + +// Error read BadPort +func BadPortErrorNew(buf []byte) xgb.Error { + v := BadPortError{} + v.NiceName = "BadPort" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadPortError) ImplementsError() {} + +func (err BadPortError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPortError) BadId() uint32 { + return 0 +} + +func (err BadPortError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +} + +// Error definition BadEncoding (1) +// Size: 32 + +const BadBadEncoding = 1 + +type BadEncodingError struct { + Sequence uint16 + NiceName string +} + +// Error read BadEncoding +func BadEncodingErrorNew(buf []byte) xgb.Error { + v := BadEncodingError{} + v.NiceName = "BadEncoding" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadEncodingError) ImplementsError() {} + +func (err BadEncodingError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadEncodingError) BadId() uint32 { + return 0 +} + +func (err BadEncodingError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew +} + +// Error definition BadControl (2) +// Size: 32 + +const BadBadControl = 2 + +type BadControlError struct { + Sequence uint16 + NiceName string +} + +// Error read BadControl +func BadControlErrorNew(buf []byte) xgb.Error { + v := BadControlError{} + v.NiceName = "BadControl" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadControlError) ImplementsError() {} + +func (err BadControlError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadControlError) BadId() uint32 { + return 0 +} + +func (err BadControlError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew +} + +// Request QueryExtension +// size: 4 +type QueryExtensionCookie struct { + *xgb.Cookie +} + +func QueryExtension(c *xgb.Conn) QueryExtensionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} +} + +func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} +} + +// Request reply for QueryExtension +// size: 12 +type QueryExtensionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Major uint16 + Minor uint16 +} + +// Waits and reads reply data from request QueryExtension +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtension +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) + 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 QueryExtension +func queryExtensionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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 QueryAdaptors +// size: 8 +type QueryAdaptorsCookie struct { + *xgb.Cookie +} + +func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} +} + +func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} +} + +// Request reply for QueryAdaptors +// size: (32 + AdaptorInfoListSize(Info)) +type QueryAdaptorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAdaptors uint16 + // padding: 22 bytes + Info []AdaptorInfo // size: AdaptorInfoListSize(Info) +} + +// Waits and reads reply data from request QueryAdaptors +func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryAdaptorsReply(buf), nil +} + +// Read reply into structure from buffer for QueryAdaptors +func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { + v := new(QueryAdaptorsReply) + 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.NumAdaptors = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]AdaptorInfo, v.NumAdaptors) + b += AdaptorInfoReadList(buf[b:], v.Info) + + return v +} + +// Write request to wire for QueryAdaptors +func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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 QueryEncodings +// size: 8 +type QueryEncodingsCookie struct { + *xgb.Cookie +} + +func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} +} + +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} +} + +// Request reply for QueryEncodings +// size: (32 + EncodingInfoListSize(Info)) +type QueryEncodingsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) +} + +// Waits and reads reply data from request QueryEncodings +func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryEncodingsReply(buf), nil +} + +// Read reply into structure from buffer for QueryEncodings +func queryEncodingsReply(buf []byte) *QueryEncodingsReply { + v := new(QueryEncodingsReply) + 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.NumEncodings = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]EncodingInfo, v.NumEncodings) + b += EncodingInfoReadList(buf[b:], v.Info) + + return v +} + +// Write request to wire for QueryEncodings +func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + return buf +} + +// Request GrabPort +// size: 12 +type GrabPortCookie struct { + *xgb.Cookie +} + +func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +// Request reply for GrabPort +// size: 8 +type GrabPortReply struct { + Sequence uint16 + Length uint32 + Result byte +} + +// Waits and reads reply data from request GrabPort +func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabPortReply(buf), nil +} + +// Read reply into structure from buffer for GrabPort +func grabPortReply(buf []byte) *GrabPortReply { + v := new(GrabPortReply) + b := 1 // skip reply determinant + + v.Result = buf[b] + 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 GrabPort +func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request UngrabPort +// size: 12 +type UngrabPortCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabPort +func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +func (cook UngrabPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPort +func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request PutVideo +// size: 32 +type PutVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutVideo +func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} +} + +func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} +} + +func (cook PutVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutVideo +func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request PutStill +// size: 32 +type PutStillCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutStill +func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} +} + +func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} +} + +func (cook PutStillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutStill +func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request GetVideo +// size: 32 +type GetVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for GetVideo +func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +func (cook GetVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetVideo +func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request GetStill +// size: 32 +type GetStillCookie struct { + *xgb.Cookie +} + +// Write request to wire for GetStill +func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} +} + +func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} +} + +func (cook GetStillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetStill +func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request StopVideo +// size: 12 +type StopVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for StopVideo +func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +func (cook StopVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StopVideo +func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request SelectVideoNotify +// size: 12 +type SelectVideoNotifyCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectVideoNotify +func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +func (cook SelectVideoNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectVideoNotify +func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request SelectPortNotify +// size: 12 +type SelectPortNotifyCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectPortNotify +func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +func (cook SelectPortNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectPortNotify +func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request QueryBestSize +// size: 20 +type QueryBestSizeCookie struct { + *xgb.Cookie +} + +func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) + return QueryBestSizeCookie{cookie} +} + +func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) + return QueryBestSizeCookie{cookie} +} + +// Request reply for QueryBestSize +// size: 12 +type QueryBestSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ActualWidth uint16 + ActualHeight uint16 +} + +// Waits and reads reply data from request QueryBestSize +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryBestSizeReply(buf), nil +} + +// Read reply into structure from buffer for QueryBestSize +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) + 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.ActualWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ActualHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryBestSize +func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + if Motion { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetPortAttribute +// size: 16 +type SetPortAttributeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPortAttribute +func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} + +func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} + +func (cook SetPortAttributeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPortAttribute +func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(Value)) + b += 4 + + return buf +} + +// Request GetPortAttribute +// size: 12 +type GetPortAttributeCookie struct { + *xgb.Cookie +} + +func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} +} + +func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} +} + +// Request reply for GetPortAttribute +// size: 12 +type GetPortAttributeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Value int32 +} + +// Waits and reads reply data from request GetPortAttribute +func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPortAttributeReply(buf), nil +} + +// Read reply into structure from buffer for GetPortAttribute +func getPortAttributeReply(buf []byte) *GetPortAttributeReply { + v := new(GetPortAttributeReply) + 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.Value = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetPortAttribute +func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + return buf +} + +// Request QueryPortAttributes +// size: 8 +type QueryPortAttributesCookie struct { + *xgb.Cookie +} + +func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// Request reply for QueryPortAttributes +// size: (32 + AttributeInfoListSize(Attributes)) +type QueryPortAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttributes uint32 + TextSize uint32 + // padding: 16 bytes + Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) +} + +// Waits and reads reply data from request QueryPortAttributes +func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPortAttributesReply(buf), nil +} + +// Read reply into structure from buffer for QueryPortAttributes +func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { + v := new(QueryPortAttributesReply) + 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.NumAttributes = xgb.Get32(buf[b:]) + b += 4 + + v.TextSize = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Attributes = make([]AttributeInfo, v.NumAttributes) + b += AttributeInfoReadList(buf[b:], v.Attributes) + + return v +} + +// Write request to wire for QueryPortAttributes +func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request ListImageFormats +// size: 8 +type ListImageFormatsCookie struct { + *xgb.Cookie +} + +func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} +} + +func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} +} + +// Request reply for ListImageFormats +// size: (32 + ImageFormatInfoListSize(Format)) +type ListImageFormatsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFormats uint32 + // padding: 20 bytes + Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) +} + +// Waits and reads reply data from request ListImageFormats +func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listImageFormatsReply(buf), nil +} + +// Read reply into structure from buffer for ListImageFormats +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + 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.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) + + return v +} + +// Write request to wire for ListImageFormats +func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request QueryImageAttributes +// size: 16 +type QueryImageAttributesCookie struct { + *xgb.Cookie +} + +func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) + return QueryImageAttributesCookie{cookie} +} + +func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) + return QueryImageAttributesCookie{cookie} +} + +// Request reply for QueryImageAttributes +// size: ((32 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) +type QueryImageAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumPlanes uint32 + DataSize uint32 + Width uint16 + Height uint16 + // padding: 12 bytes + Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) +} + +// Waits and reads reply data from request QueryImageAttributes +func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryImageAttributesReply(buf), nil +} + +// Read reply into structure from buffer for QueryImageAttributes +func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { + v := new(QueryImageAttributesReply) + 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.NumPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.DataSize = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 12 // padding + + v.Pitches = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Pitches[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Offsets = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Offsets[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryImageAttributes +func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request PutImage +// size: xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +type PutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutImage +func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} +} + +func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} +} + +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request ShmPutImage +// size: 52 +type ShmPutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for ShmPutImage +func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) + return ShmPutImageCookie{cookie} +} + +func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) + return ShmPutImageCookie{cookie} +} + +func (cook ShmPutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ShmPutImage +func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { + size := 52 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + buf[b] = SendEvent + b += 1 + + b += 3 // padding + + return buf +} diff --git a/nexgb/xvmc/xvmc.go b/nexgb/xvmc/xvmc.go new file mode 100644 index 0000000..8878acf --- /dev/null +++ b/nexgb/xvmc/xvmc.go @@ -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 +} -- cgit v1.2.3-70-g09d2 From 4b20ffaf4f4cc756832a6d064d5dfe182f16b0e9 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:42:36 -0400 Subject: Updated to work with new xproto XML files. Namely, the "doc" element is ignored. Also, I've sorted everything before output so that diff isn't completely useless. --- nexgb/xgbgen/context.go | 5 +++++ nexgb/xgbgen/protocol.go | 6 ++++++ nexgb/xgbgen/request_reply.go | 6 ++++++ nexgb/xgbgen/translation.go | 28 ++++++++++++++++++---------- nexgb/xgbgen/type.go | 10 ++++++++++ 5 files changed, 45 insertions(+), 10 deletions(-) (limited to 'nexgb/xgbgen/protocol.go') diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index c40313f..697413e 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -5,6 +5,7 @@ import ( "encoding/xml" "fmt" "log" + "sort" "time" ) @@ -70,6 +71,8 @@ func (c *Context) Morph(xmlBytes []byte) { if c.protocol.isExt() { c.Putln("\"github.com/BurntSushi/xgb/xproto\"") } + + sort.Sort(Protocols(c.protocol.Imports)) for _, imp := range c.protocol.Imports { // We always import xproto, so skip it if it's explicitly imported if imp.Name == "xproto" { @@ -142,6 +145,8 @@ func (c *Context) Morph(xmlBytes []byte) { } // Now write Go source code + sort.Sort(Types(c.protocol.Types)) + sort.Sort(Requests(c.protocol.Requests)) for _, typ := range c.protocol.Types { typ.Define(c) } diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index d56663d..433f4e2 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -22,6 +22,12 @@ type Protocol struct { Requests []*Request } +type Protocols []*Protocol + +func (ps Protocols) Len() int { return len(ps) } +func (ps Protocols) Swap(i, j int) { ps[i], ps[j] = ps[j], ps[i] } +func (ps Protocols) Less(i, j int) bool { return ps[i].ExtName < ps[j].ExtName } + // Initialize traverses all structures, looks for 'Translation' type, // and looks up the real type in the namespace. It also sets the source // name for all relevant fields/structures. diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index b8afe48..11a4e44 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -17,6 +17,12 @@ type Request struct { Reply *Reply // A reply, if one exists for this request. } +type Requests []*Request + +func (rs Requests) Len() int { return len(rs) } +func (rs Requests) Swap(i, j int) { rs[i], rs[j] = rs[j], rs[i] } +func (rs Requests) Less(i, j int) bool { return rs[i].xmlName < rs[j].xmlName } + // Initialize creates the proper Go source name for this request. // It also initializes the reply if one exists, and all fields in this request. func (r *Request) Initialize(p *Protocol) { diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 0123669..778304f 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -137,10 +137,13 @@ func (x *XMLEvent) Translate() *Event { xmlName: x.Name, Number: x.Number, NoSequence: x.NoSequence, - Fields: make([]Field, len(x.Fields)), + Fields: make([]Field, 0, len(x.Fields)), } - for i, field := range x.Fields { - ev.Fields[i] = field.Translate(ev) + for _, field := range x.Fields { + if field.XMLName.Local == "doc" { + continue + } + ev.Fields = append(ev.Fields, field.Translate(ev)) } return ev } @@ -200,11 +203,14 @@ func (x *XMLRequest) Translate() *Request { xmlName: x.Name, Opcode: x.Opcode, Combine: x.Combine, - Fields: make([]Field, len(x.Fields)), + Fields: make([]Field, 0, len(x.Fields)), Reply: x.Reply.Translate(), } - for i, field := range x.Fields { - r.Fields[i] = field.Translate(r) + for _, field := range x.Fields { + if field.XMLName.Local == "doc" { + continue + } + r.Fields = append(r.Fields, field.Translate(r)) } // Address bug (or legacy code) in QueryTextExtents. @@ -229,10 +235,13 @@ func (x *XMLReply) Translate() *Reply { } r := &Reply{ - Fields: make([]Field, len(x.Fields)), + Fields: make([]Field, 0, len(x.Fields)), } - for i, field := range x.Fields { - r.Fields[i] = field.Translate(r) + for _, field := range x.Fields { + if field.XMLName.Local == "doc" { + continue + } + r.Fields = append(r.Fields, field.Translate(r)) } return r } @@ -380,7 +389,6 @@ func SrcName(p *Protocol, name string) string { if newn, ok := NameMap[name]; ok { return newn } - return splitAndTitle(name) } diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index 521f67e..ded5be2 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -14,6 +14,16 @@ type Type interface { Define(c *Context) } +type Types []Type + +func (ts Types) Len() int { return len(ts) } +func (ts Types) Swap(i, j int) { ts[i], ts[j] = ts[j], ts[i] } +func (ts Types) Less(i, j int) bool { + x1, x2 := ts[i].XmlName(), ts[j].XmlName() + s1, s2 := ts[i].SrcName(), ts[j].SrcName() + return (s1 == s2 && x1 < x2) || s1 < s2 +} + // Translation is used *only* when transitioning from XML types to // our better representation. They are placeholders for the real types (below) // that will replace them. -- cgit v1.2.3-70-g09d2