func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
	c.ExtLock.RLock()
	defer c.ExtLock.RUnlock()
	if _, ok := c.Extensions["MIT-SHM"]; !ok {
		panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
	}
	cookie := c.NewCookie(false, false)
	c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
	return CreatePixmapCookie{cookie}
}
CreatePixmap sends an unchecked request.
If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
package shm
import (
	"github.com/BurntSushi/xgb"
	"github.com/BurntSushi/xgb/xproto"
)
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.")
	}
	c.ExtLock.Lock()
	c.Extensions["MIT-SHM"] = reply.MajorOpcode
	c.ExtLock.Unlock()
	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
	}
	return nil
}
func init() {
	xgb.NewExtEventFuncs["MIT-SHM"] = make(map[int]xgb.NewEventFun)
	xgb.NewExtErrorFuncs["MIT-SHM"] = make(map[int]xgb.NewErrorFun)
}
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) 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
}
const Completion = 0
type CompletionEvent struct {
	Sequence uint16
	Drawable   xproto.Drawable
	MinorEvent uint16
	MajorEvent byte
	Shmseg Seg
	Offset uint32
}
func CompletionEventNew(buf []byte) xgb.Event {
	v := CompletionEvent{}
	b := 1  
	b += 1  
	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  
	v.Shmseg = Seg(xgb.Get32(buf[b:]))
	b += 4
	v.Offset = xgb.Get32(buf[b:])
	b += 4
	return v
}
func (v CompletionEvent) Bytes() []byte {
	buf := make([]byte, 32)
	b := 0
	buf[b] = 0
	b += 1
	b += 1  
	b += 2  
	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  
	xgb.Put32(buf[b:], uint32(v.Shmseg))
	b += 4
	xgb.Put32(buf[b:], v.Offset)
	b += 4
	return buf
}
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
}
type Seg uint32
func NewSegId(c *xgb.Conn) (Seg, error) {
	id, err := c.NewId()
	if err != nil {
		return 0, err
	}
	return Seg(id), nil
}
type AttachCookie struct {
	*xgb.Cookie
}
func Attach(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie {
	c.ExtLock.RLock()
	defer c.ExtLock.RUnlock()
	if _, ok := c.Extensions["MIT-SHM"]; !ok {
		panic("Cannot issue request 'Attach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
	}
	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 {
	c.ExtLock.RLock()
	defer c.ExtLock.RUnlock()
	if _, ok := c.Extensions["MIT-SHM"]; !ok {
		panic("Cannot issue request 'Attach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
	}
	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()
}
func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte {
	size := 16
	b := 0
	buf := make([]byte, size)
	c.ExtLock.RLock()
	buf[b] = c.Extensions["MIT-SHM"]
	c.ExtLock.RUnlock()
	b += 1
	buf[b] = 1  
	b += 1
	xgb.Put16(buf[b:], uint16(size/4))  
	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  
	return buf
}
type AttachFdCookie struct {
	*xgb.Cookie
}
func AttachFd(c *xgb.Conn, Shmseg Seg, ReadOnly bool) AttachFdCookie {
	c.ExtLock.RLock()
	defer c.ExtLock.RUnlock()
	if _, ok := c.Extensions["MIT-SHM"]; !ok {
		panic("Cannot issue request 'AttachFd' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
	}
	cookie := c.NewCookie(false, false)
	c.NewRequest(attachFdRequest(c, Shmseg, ReadOnly), cookie)
	return AttachFdCookie{cookie}
}
func AttachFdChecked(c *xgb.Conn, Shmseg Seg, ReadOnly bool) AttachFdCookie {
	c.ExtLock.RLock()
	defer c.ExtLock.RUnlock()
	if _, ok := c.Extensions["MIT-SHM"]; !ok {
		panic("Cannot issue request 'AttachFd' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
	}
	cookie := c.NewCookie(true, false)
	c.NewRequest(attachFdRequest(c, Shmseg, ReadOnly), cookie)
	return AttachFdCookie{cookie}
}
func (cook AttachFdCookie) Check() error {
	return cook.Cookie.Check()
}
func attachFdRequest(c *xgb.Conn, Shmseg Seg, ReadOnly bool) []byte {
	size := 12
	b := 0
	buf := make([]byte, size)
	c.ExtLock.RLock()
	buf[b] = c.Extensions["MIT-SHM"]
	c.ExtLock.RUnlock()
	b += 1
	buf[b] = 6  
	b += 1
	xgb.Put16(buf[b:], uint16(size/4))  
	b += 2
	xgb.Put32(buf[b:], uint32(Shmseg))
	b += 4
	if ReadOnly {
		buf[b] = 1
	} else {
		buf[b] = 0
	}
	b += 1
	b += 3  
	return buf
}
type CreatePixmapCookie struct {
	*xgb.Cookie
}