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 }