Categorygithub.com/robotn/xgb
modulepackage
0.10.0
Repository: https://github.com/robotn/xgb.git
Documentation: pkg.go.dev

# README

XGB is 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 closely modeled after XCB and xpyb.

It is thread safe and gets immediate improvement from parallelism when GOMAXPROCS > 1. (See the benchmarks in xproto/xproto_test.go for evidence.)

Please see doc.go for more info.

Note that unless you know you need XGB, you can probably make your life easier by using a slightly higher level library: xgbutil.

Quick Usage

go get github.com/robotn/xgb go run go/path/src/github.com/robotn/xgb/examples/create-window/main.go

BurntSushi's Fork

I've forked the XGB repository from Google Code due to inactivty upstream.

Godoc documentation can be found here: http://godoc.burntsushi.net/pkg/github.com/robotn/xgb/

Much of the code has been rewritten in an effort to support thread safety and multiple extensions. Namely, go_client.py has been thrown away in favor of an xgbgen package.

The biggest parts that haven't been rewritten by me are the connection and authentication handshakes. They're inherently messy, and there's really no reason to re-work them. The rest of XGB has been completely rewritten.

I like to release my code under the WTFPL, but since I'm starting with someone else's work, I'm leaving the original license/contributor/author information in tact.

I suppose I can legitimately release xgbgen under the WTFPL. To be fair, it is at least as complex as XGB itself. sigh

What follows is the original README:

XGB README

XGB is the X protocol Go language Binding.

It is the Go equivalent of XCB, the X protocol C-language Binding (http://xcb.freedesktop.org/).

Unless otherwise noted, the XGB source files are distributed under the BSD-style license found in the LICENSE file.

Contributions should follow the same procedure as for the Go project: http://golang.org/doc/contribute.html

# Packages

Package bigreq is the X client API for the BIG-REQUESTS extension.
Package composite is the X client API for the Composite extension.
Package damage is the X client API for the DAMAGE extension.
Package dpms is the X client API for the DPMS extension.
Package dri2 is the X client API for the DRI2 extension.
No description provided by the author
Package ge is the X client API for the Generic Event Extension extension.
Package glx is the X client API for the GLX extension.
Package randr is the X client API for the RANDR extension.
Package record is the X client API for the RECORD extension.
Package render is the X client API for the RENDER extension.
Package res is the X client API for the X-Resource extension.
Package screensaver is the X client API for the MIT-SCREEN-SAVER extension.
Package shape is the X client API for the SHAPE extension.
Package shm is the X client API for the MIT-SHM extension.
Package xcmisc is the X client API for the XC-MISC extension.
Package xevie is the X client API for the XEVIE extension.
Package xf86dri is the X client API for the XFree86-DRI extension.
Package xf86vidmode is the X client API for the XFree86-VidModeExtension extension.
Package xfixes is the X client API for the XFIXES extension.
xgbgen constructs Go source files from xproto XML description files.
Package xinerama is the X client API for the XINERAMA extension.
Package xprint is the X client API for the XpExtension extension.
Package xproto is the X client API for the extension.
Package xselinux is the X client API for the SELinux extension.
Package xtest is the X client API for the XTEST extension.
Package xv is the X client API for the XVideo extension.
Package xvmc is the X client API for the XVideo-MotionCompensation extension.

# Functions

Errorf is just a wrapper for fmt.Errorf.
Get16 constructs a 16 bit integer from the beginning of a byte slice.
Get32 constructs a 32 bit integer from the beginning of a byte slice.
Get64 constructs a 64 bit integer from the beginning of a byte slice.
NewConn creates a new connection instance.
NewConnDisplay is just like NewConn, but allows a specific DISPLAY string to be used.
NewConnDisplay is just like NewConn, but allows a specific net.Conn to be used.
Pad a length to align on 4 bytes.
PopCount counts the number of bits set in a value list mask.
Put16 takes a 16 bit integer and copies it into a byte slice.
Put32 takes a 32 bit integer and copies it into a byte slice.
Put64 takes a 64 bit integer and copies it into a byte slice.
Sprintf is so we don't need to import 'fmt' in the generated Go files.
StringsJoin is an alias to strings.Join.

# Variables

Where to log error-messages.
NewErrorFuncs is a map from error numbers to functions that create the corresponding error.
NewEventFuncs is a map from event numbers to functions that create the corresponding event.
NewExtErrorFuncs is a temporary map that stores error constructor functions for each extension.
NewExtEventFuncs is a temporary map that stores event constructor functions for each extension.

# Structs

A Conn represents a connection to an X server.
Cookie is the internal representation of a cookie, where one is generated for *every* request sent by XGB.

# Interfaces

Error is an interface that can contain any of the errors returned by the server.
Event is an interface that can contain any of the events returned by the server.

# Type aliases

NewErrorFun is the type of function use to construct errors from raw bytes.
NewEventFun is the type of function use to construct events from raw bytes.