// Code generated by xtgen; DO NOT EDIT. package xproto import "encoding/binary" // GetWindowAttributesReply is a zero-copy view over a GetWindowAttributes reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetWindowAttributesReply struct{ raw []byte } // ParseGetWindowAttributesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetWindowAttributesReply(raw []byte) (GetWindowAttributesReply, bool) { if len(raw) < 44 { return GetWindowAttributesReply{}, false } r := GetWindowAttributesReply{raw: raw} return r, true } func (r GetWindowAttributesReply) Raw() []byte { return r.raw } func (r GetWindowAttributesReply) BackingStore() BackingStore { return BackingStore(r.raw[1:][0]) } func (r GetWindowAttributesReply) Visual() Visualid { return Visualid(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetWindowAttributesReply) Class() WindowClass { return WindowClass(binary.LittleEndian.Uint16(r.raw[12:])) } func (r GetWindowAttributesReply) BitGravity() Gravity { return Gravity(r.raw[14:][0]) } func (r GetWindowAttributesReply) WinGravity() Gravity { return Gravity(r.raw[15:][0]) } func (r GetWindowAttributesReply) BackingPlanes() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) } func (r GetWindowAttributesReply) BackingPixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[20:])) } func (r GetWindowAttributesReply) SaveUnder() bool { return (r.raw[24:][0] != 0) } func (r GetWindowAttributesReply) MapIsInstalled() bool { return (r.raw[25:][0] != 0) } func (r GetWindowAttributesReply) MapState() MapState { return MapState(r.raw[26:][0]) } func (r GetWindowAttributesReply) OverrideRedirect() bool { return (r.raw[27:][0] != 0) } func (r GetWindowAttributesReply) Colormap() Colormap { return Colormap(binary.LittleEndian.Uint32(r.raw[28:])) } func (r GetWindowAttributesReply) AllEventMasks() EventMask { return EventMask(binary.LittleEndian.Uint32(r.raw[32:])) } func (r GetWindowAttributesReply) YourEventMask() EventMask { return EventMask(binary.LittleEndian.Uint32(r.raw[36:])) } func (r GetWindowAttributesReply) DoNotPropagateMask() EventMask { return EventMask(binary.LittleEndian.Uint16(r.raw[40:])) } // GetGeometryReply is a zero-copy view over a GetGeometry reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetGeometryReply struct{ raw []byte } // ParseGetGeometryReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetGeometryReply(raw []byte) (GetGeometryReply, bool) { if len(raw) < 32 { return GetGeometryReply{}, false } r := GetGeometryReply{raw: raw} return r, true } func (r GetGeometryReply) Raw() []byte { return r.raw } func (r GetGeometryReply) Depth() uint8 { return uint8(r.raw[1:][0]) } func (r GetGeometryReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetGeometryReply) X() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) } func (r GetGeometryReply) Y() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) } func (r GetGeometryReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } func (r GetGeometryReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) } func (r GetGeometryReply) BorderWidth() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[20:])) } // QueryTreeReply is a zero-copy view over a QueryTree reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryTreeReply struct{ raw []byte } // ParseQueryTreeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryTreeReply(raw []byte) (QueryTreeReply, bool) { if len(raw) < 32 { return QueryTreeReply{}, false } r := QueryTreeReply{raw: raw} off := 32 { n := int(r.ChildrenLen()) if n < 0 || n > len(r.raw) { return QueryTreeReply{}, false } off += n * 4 } if off > len(r.raw) { return QueryTreeReply{}, false } if off > len(r.raw) { return QueryTreeReply{}, false } return r, true } func (r QueryTreeReply) Raw() []byte { return r.raw } func (r QueryTreeReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryTreeReply) Parent() Window { return Window(binary.LittleEndian.Uint32(r.raw[12:])) } func (r QueryTreeReply) ChildrenLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } func (r QueryTreeReply) Children() WindowList { off := 32 end := off + (int(r.ChildrenLen()))*4 return WindowList{b: r.raw[off:end:end]} } // InternAtomReply is a zero-copy view over a InternAtom reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type InternAtomReply struct{ raw []byte } // ParseInternAtomReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseInternAtomReply(raw []byte) (InternAtomReply, bool) { if len(raw) < 32 { return InternAtomReply{}, false } r := InternAtomReply{raw: raw} return r, true } func (r InternAtomReply) Raw() []byte { return r.raw } func (r InternAtomReply) Atom() Atom { return Atom(binary.LittleEndian.Uint32(r.raw[8:])) } // GetAtomNameReply is a zero-copy view over a GetAtomName reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetAtomNameReply struct{ raw []byte } // ParseGetAtomNameReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetAtomNameReply(raw []byte) (GetAtomNameReply, bool) { if len(raw) < 32 { return GetAtomNameReply{}, false } r := GetAtomNameReply{raw: raw} off := 32 { n := int(r.NameLen()) if n < 0 || n > len(r.raw) { return GetAtomNameReply{}, false } off += n * 1 } if off > len(r.raw) { return GetAtomNameReply{}, false } if off > len(r.raw) { return GetAtomNameReply{}, false } return r, true } func (r GetAtomNameReply) Raw() []byte { return r.raw } func (r GetAtomNameReply) NameLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r GetAtomNameReply) Name() []byte { off := 32 end := off + int(r.NameLen()) return r.raw[off:end:end] } // GetPropertyReply is a zero-copy view over a GetProperty reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetPropertyReply struct{ raw []byte } // ParseGetPropertyReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetPropertyReply(raw []byte) (GetPropertyReply, bool) { if len(raw) < 32 { return GetPropertyReply{}, false } r := GetPropertyReply{raw: raw} off := 32 { n := (int(r.ValueLen()) * (int(r.Format()) / 8)) if n < 0 || n > len(r.raw) { return GetPropertyReply{}, false } off += n * 1 } if off > len(r.raw) { return GetPropertyReply{}, false } if off > len(r.raw) { return GetPropertyReply{}, false } return r, true } func (r GetPropertyReply) Raw() []byte { return r.raw } func (r GetPropertyReply) Format() uint8 { return uint8(r.raw[1:][0]) } func (r GetPropertyReply) Type() Atom { return Atom(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetPropertyReply) BytesAfter() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) } func (r GetPropertyReply) ValueLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) } func (r GetPropertyReply) Value() []byte { off := 32 end := off + (int(r.ValueLen()) * (int(r.Format()) / 8)) return r.raw[off:end:end] } // ListPropertiesReply is a zero-copy view over a ListProperties reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type ListPropertiesReply struct{ raw []byte } // ParseListPropertiesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseListPropertiesReply(raw []byte) (ListPropertiesReply, bool) { if len(raw) < 32 { return ListPropertiesReply{}, false } r := ListPropertiesReply{raw: raw} off := 32 { n := int(r.AtomsLen()) if n < 0 || n > len(r.raw) { return ListPropertiesReply{}, false } off += n * 4 } if off > len(r.raw) { return ListPropertiesReply{}, false } if off > len(r.raw) { return ListPropertiesReply{}, false } return r, true } func (r ListPropertiesReply) Raw() []byte { return r.raw } func (r ListPropertiesReply) AtomsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r ListPropertiesReply) Atoms() AtomList { off := 32 end := off + (int(r.AtomsLen()))*4 return AtomList{b: r.raw[off:end:end]} } // GetSelectionOwnerReply is a zero-copy view over a GetSelectionOwner reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetSelectionOwnerReply struct{ raw []byte } // ParseGetSelectionOwnerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetSelectionOwnerReply(raw []byte) (GetSelectionOwnerReply, bool) { if len(raw) < 32 { return GetSelectionOwnerReply{}, false } r := GetSelectionOwnerReply{raw: raw} return r, true } func (r GetSelectionOwnerReply) Raw() []byte { return r.raw } func (r GetSelectionOwnerReply) Owner() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } // GrabPointerReply is a zero-copy view over a GrabPointer reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GrabPointerReply struct{ raw []byte } // ParseGrabPointerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGrabPointerReply(raw []byte) (GrabPointerReply, bool) { if len(raw) < 32 { return GrabPointerReply{}, false } r := GrabPointerReply{raw: raw} return r, true } func (r GrabPointerReply) Raw() []byte { return r.raw } func (r GrabPointerReply) Status() GrabStatus { return GrabStatus(r.raw[1:][0]) } // GrabKeyboardReply is a zero-copy view over a GrabKeyboard reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GrabKeyboardReply struct{ raw []byte } // ParseGrabKeyboardReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGrabKeyboardReply(raw []byte) (GrabKeyboardReply, bool) { if len(raw) < 32 { return GrabKeyboardReply{}, false } r := GrabKeyboardReply{raw: raw} return r, true } func (r GrabKeyboardReply) Raw() []byte { return r.raw } func (r GrabKeyboardReply) Status() GrabStatus { return GrabStatus(r.raw[1:][0]) } // QueryPointerReply is a zero-copy view over a QueryPointer reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryPointerReply struct{ raw []byte } // ParseQueryPointerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryPointerReply(raw []byte) (QueryPointerReply, bool) { if len(raw) < 32 { return QueryPointerReply{}, false } r := QueryPointerReply{raw: raw} return r, true } func (r QueryPointerReply) Raw() []byte { return r.raw } func (r QueryPointerReply) SameScreen() bool { return (r.raw[1:][0] != 0) } func (r QueryPointerReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } func (r QueryPointerReply) Child() Window { return Window(binary.LittleEndian.Uint32(r.raw[12:])) } func (r QueryPointerReply) RootX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[16:])) } func (r QueryPointerReply) RootY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[18:])) } func (r QueryPointerReply) WinX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[20:])) } func (r QueryPointerReply) WinY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[22:])) } func (r QueryPointerReply) Mask() KeyButMask { return KeyButMask(binary.LittleEndian.Uint16(r.raw[24:])) } // GetMotionEventsReply is a zero-copy view over a GetMotionEvents reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetMotionEventsReply struct{ raw []byte } // ParseGetMotionEventsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetMotionEventsReply(raw []byte) (GetMotionEventsReply, bool) { if len(raw) < 32 { return GetMotionEventsReply{}, false } r := GetMotionEventsReply{raw: raw} off := 32 { n := int(r.EventsLen()) if n < 0 || n > len(r.raw) { return GetMotionEventsReply{}, false } off += n * 8 } if off > len(r.raw) { return GetMotionEventsReply{}, false } if off > len(r.raw) { return GetMotionEventsReply{}, false } return r, true } func (r GetMotionEventsReply) Raw() []byte { return r.raw } func (r GetMotionEventsReply) EventsLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetMotionEventsReply) Events() TimecoordList { off := 32 end := off + (int(r.EventsLen()))*8 return TimecoordList{b: r.raw[off:end:end]} } // TranslateCoordinatesReply is a zero-copy view over a TranslateCoordinates reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type TranslateCoordinatesReply struct{ raw []byte } // ParseTranslateCoordinatesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseTranslateCoordinatesReply(raw []byte) (TranslateCoordinatesReply, bool) { if len(raw) < 32 { return TranslateCoordinatesReply{}, false } r := TranslateCoordinatesReply{raw: raw} return r, true } func (r TranslateCoordinatesReply) Raw() []byte { return r.raw } func (r TranslateCoordinatesReply) SameScreen() bool { return (r.raw[1:][0] != 0) } func (r TranslateCoordinatesReply) Child() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } func (r TranslateCoordinatesReply) DstX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) } func (r TranslateCoordinatesReply) DstY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) } // GetInputFocusReply is a zero-copy view over a GetInputFocus reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetInputFocusReply struct{ raw []byte } // ParseGetInputFocusReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetInputFocusReply(raw []byte) (GetInputFocusReply, bool) { if len(raw) < 32 { return GetInputFocusReply{}, false } r := GetInputFocusReply{raw: raw} return r, true } func (r GetInputFocusReply) Raw() []byte { return r.raw } func (r GetInputFocusReply) RevertTo() InputFocus { return InputFocus(r.raw[1:][0]) } func (r GetInputFocusReply) Focus() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } // QueryKeymapReply is a zero-copy view over a QueryKeymap reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryKeymapReply struct{ raw []byte } // ParseQueryKeymapReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryKeymapReply(raw []byte) (QueryKeymapReply, bool) { if len(raw) < 40 { return QueryKeymapReply{}, false } r := QueryKeymapReply{raw: raw} return r, true } func (r QueryKeymapReply) Raw() []byte { return r.raw } func (r QueryKeymapReply) Keys() []byte { off := 8; end := off + 32; return r.raw[off:end:end] } // QueryFontReply is a zero-copy view over a QueryFont reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryFontReply struct{ raw []byte } // ParseQueryFontReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryFontReply(raw []byte) (QueryFontReply, bool) { if len(raw) < 60 { return QueryFontReply{}, false } r := QueryFontReply{raw: raw} off := 60 { n := int(r.PropertiesLen()) if n < 0 || n > len(r.raw) { return QueryFontReply{}, false } off += n * 8 } if off > len(r.raw) { return QueryFontReply{}, false } { n := int(r.CharInfosLen()) if n < 0 || n > len(r.raw) { return QueryFontReply{}, false } off += n * 12 } if off > len(r.raw) { return QueryFontReply{}, false } if off > len(r.raw) { return QueryFontReply{}, false } return r, true } func (r QueryFontReply) Raw() []byte { return r.raw } func (r QueryFontReply) MinBounds() Charinfo { return GetCharinfo(r.raw[8:]) } func (r QueryFontReply) MaxBounds() Charinfo { return GetCharinfo(r.raw[24:]) } func (r QueryFontReply) MinCharOrByte2() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[40:])) } func (r QueryFontReply) MaxCharOrByte2() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[42:])) } func (r QueryFontReply) DefaultChar() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[44:])) } func (r QueryFontReply) PropertiesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[46:])) } func (r QueryFontReply) DrawDirection() FontDraw { return FontDraw(r.raw[48:][0]) } func (r QueryFontReply) MinByte1() uint8 { return uint8(r.raw[49:][0]) } func (r QueryFontReply) MaxByte1() uint8 { return uint8(r.raw[50:][0]) } func (r QueryFontReply) AllCharsExist() bool { return (r.raw[51:][0] != 0) } func (r QueryFontReply) FontAscent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[52:])) } func (r QueryFontReply) FontDescent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[54:])) } func (r QueryFontReply) CharInfosLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[56:])) } func (r QueryFontReply) Properties() FontpropList { off := 60 end := off + (int(r.PropertiesLen()))*8 return FontpropList{b: r.raw[off:end:end]} } func (r QueryFontReply) CharInfos() CharinfoList { off := 60 { n := int(r.PropertiesLen()) off += n * 8 } end := off + (int(r.CharInfosLen()))*12 return CharinfoList{b: r.raw[off:end:end]} } // QueryTextExtentsReply is a zero-copy view over a QueryTextExtents reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryTextExtentsReply struct{ raw []byte } // ParseQueryTextExtentsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryTextExtentsReply(raw []byte) (QueryTextExtentsReply, bool) { if len(raw) < 32 { return QueryTextExtentsReply{}, false } r := QueryTextExtentsReply{raw: raw} return r, true } func (r QueryTextExtentsReply) Raw() []byte { return r.raw } func (r QueryTextExtentsReply) DrawDirection() FontDraw { return FontDraw(r.raw[1:][0]) } func (r QueryTextExtentsReply) FontAscent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r QueryTextExtentsReply) FontDescent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[10:])) } func (r QueryTextExtentsReply) OverallAscent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) } func (r QueryTextExtentsReply) OverallDescent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) } func (r QueryTextExtentsReply) OverallWidth() int32 { return int32(binary.LittleEndian.Uint32(r.raw[16:])) } func (r QueryTextExtentsReply) OverallLeft() int32 { return int32(binary.LittleEndian.Uint32(r.raw[20:])) } func (r QueryTextExtentsReply) OverallRight() int32 { return int32(binary.LittleEndian.Uint32(r.raw[24:])) } // ListFontsReply is a zero-copy view over a ListFonts reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type ListFontsReply struct{ raw []byte } // ParseListFontsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseListFontsReply(raw []byte) (ListFontsReply, bool) { if len(raw) < 32 { return ListFontsReply{}, false } r := ListFontsReply{raw: raw} off := 32 { n := int(r.NamesLen()) if off > len(r.raw) || n < 0 || n > len(r.raw) { return ListFontsReply{}, false } it := NewStrIter(r.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return ListFontsReply{}, false } } if off > len(r.raw) { return ListFontsReply{}, false } return r, true } func (r ListFontsReply) Raw() []byte { return r.raw } func (r ListFontsReply) NamesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r ListFontsReply) Names() StrIter { off := 32; return NewStrIter(r.raw[off:], int(r.NamesLen())) } // ListFontsWithInfoReply is a zero-copy view over a ListFontsWithInfo reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type ListFontsWithInfoReply struct{ raw []byte } // ParseListFontsWithInfoReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseListFontsWithInfoReply(raw []byte) (ListFontsWithInfoReply, bool) { if len(raw) < 60 { return ListFontsWithInfoReply{}, false } r := ListFontsWithInfoReply{raw: raw} off := 60 { n := int(r.PropertiesLen()) if n < 0 || n > len(r.raw) { return ListFontsWithInfoReply{}, false } off += n * 8 } if off > len(r.raw) { return ListFontsWithInfoReply{}, false } { n := int(r.NameLen()) if n < 0 || n > len(r.raw) { return ListFontsWithInfoReply{}, false } off += n * 1 } if off > len(r.raw) { return ListFontsWithInfoReply{}, false } if off > len(r.raw) { return ListFontsWithInfoReply{}, false } return r, true } func (r ListFontsWithInfoReply) Raw() []byte { return r.raw } func (r ListFontsWithInfoReply) NameLen() uint8 { return uint8(r.raw[1:][0]) } func (r ListFontsWithInfoReply) MinBounds() Charinfo { return GetCharinfo(r.raw[8:]) } func (r ListFontsWithInfoReply) MaxBounds() Charinfo { return GetCharinfo(r.raw[24:]) } func (r ListFontsWithInfoReply) MinCharOrByte2() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[40:])) } func (r ListFontsWithInfoReply) MaxCharOrByte2() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[42:])) } func (r ListFontsWithInfoReply) DefaultChar() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[44:])) } func (r ListFontsWithInfoReply) PropertiesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[46:])) } func (r ListFontsWithInfoReply) DrawDirection() FontDraw { return FontDraw(r.raw[48:][0]) } func (r ListFontsWithInfoReply) MinByte1() uint8 { return uint8(r.raw[49:][0]) } func (r ListFontsWithInfoReply) MaxByte1() uint8 { return uint8(r.raw[50:][0]) } func (r ListFontsWithInfoReply) AllCharsExist() bool { return (r.raw[51:][0] != 0) } func (r ListFontsWithInfoReply) FontAscent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[52:])) } func (r ListFontsWithInfoReply) FontDescent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[54:])) } func (r ListFontsWithInfoReply) RepliesHint() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[56:])) } func (r ListFontsWithInfoReply) Properties() FontpropList { off := 60 end := off + (int(r.PropertiesLen()))*8 return FontpropList{b: r.raw[off:end:end]} } func (r ListFontsWithInfoReply) Name() []byte { off := 60 { n := int(r.PropertiesLen()) off += n * 8 } end := off + int(r.NameLen()) return r.raw[off:end:end] } // GetFontPathReply is a zero-copy view over a GetFontPath reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetFontPathReply struct{ raw []byte } // ParseGetFontPathReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetFontPathReply(raw []byte) (GetFontPathReply, bool) { if len(raw) < 32 { return GetFontPathReply{}, false } r := GetFontPathReply{raw: raw} off := 32 { n := int(r.PathLen()) if off > len(r.raw) || n < 0 || n > len(r.raw) { return GetFontPathReply{}, false } it := NewStrIter(r.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return GetFontPathReply{}, false } } if off > len(r.raw) { return GetFontPathReply{}, false } return r, true } func (r GetFontPathReply) Raw() []byte { return r.raw } func (r GetFontPathReply) PathLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r GetFontPathReply) Path() StrIter { off := 32; return NewStrIter(r.raw[off:], int(r.PathLen())) } // GetImageReply is a zero-copy view over a GetImage reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetImageReply struct{ raw []byte } // ParseGetImageReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetImageReply(raw []byte) (GetImageReply, bool) { if len(raw) < 32 { return GetImageReply{}, false } r := GetImageReply{raw: raw} off := 32 { n := (int(binary.LittleEndian.Uint32(r.raw[4:])) * 4) if n < 0 || n > len(r.raw) { return GetImageReply{}, false } off += n * 1 } if off > len(r.raw) { return GetImageReply{}, false } if off > len(r.raw) { return GetImageReply{}, false } return r, true } func (r GetImageReply) Raw() []byte { return r.raw } func (r GetImageReply) Depth() uint8 { return uint8(r.raw[1:][0]) } func (r GetImageReply) Visual() Visualid { return Visualid(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetImageReply) Data() []byte { off := 32 end := off + (int(binary.LittleEndian.Uint32(r.raw[4:])) * 4) return r.raw[off:end:end] } // ListInstalledColormapsReply is a zero-copy view over a ListInstalledColormaps reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type ListInstalledColormapsReply struct{ raw []byte } // ParseListInstalledColormapsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseListInstalledColormapsReply(raw []byte) (ListInstalledColormapsReply, bool) { if len(raw) < 32 { return ListInstalledColormapsReply{}, false } r := ListInstalledColormapsReply{raw: raw} off := 32 { n := int(r.CmapsLen()) if n < 0 || n > len(r.raw) { return ListInstalledColormapsReply{}, false } off += n * 4 } if off > len(r.raw) { return ListInstalledColormapsReply{}, false } if off > len(r.raw) { return ListInstalledColormapsReply{}, false } return r, true } func (r ListInstalledColormapsReply) Raw() []byte { return r.raw } func (r ListInstalledColormapsReply) CmapsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r ListInstalledColormapsReply) Cmaps() ColormapList { off := 32 end := off + (int(r.CmapsLen()))*4 return ColormapList{b: r.raw[off:end:end]} } // AllocColorReply is a zero-copy view over a AllocColor reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type AllocColorReply struct{ raw []byte } // ParseAllocColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseAllocColorReply(raw []byte) (AllocColorReply, bool) { if len(raw) < 32 { return AllocColorReply{}, false } r := AllocColorReply{raw: raw} return r, true } func (r AllocColorReply) Raw() []byte { return r.raw } func (r AllocColorReply) Red() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r AllocColorReply) Green() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } func (r AllocColorReply) Blue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } func (r AllocColorReply) Pixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) } // AllocNamedColorReply is a zero-copy view over a AllocNamedColor reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type AllocNamedColorReply struct{ raw []byte } // ParseAllocNamedColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseAllocNamedColorReply(raw []byte) (AllocNamedColorReply, bool) { if len(raw) < 32 { return AllocNamedColorReply{}, false } r := AllocNamedColorReply{raw: raw} return r, true } func (r AllocNamedColorReply) Raw() []byte { return r.raw } func (r AllocNamedColorReply) Pixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r AllocNamedColorReply) ExactRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } func (r AllocNamedColorReply) ExactGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[14:])) } func (r AllocNamedColorReply) ExactBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } func (r AllocNamedColorReply) VisualRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) } func (r AllocNamedColorReply) VisualGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[20:])) } func (r AllocNamedColorReply) VisualBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[22:])) } // AllocColorCellsReply is a zero-copy view over a AllocColorCells reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type AllocColorCellsReply struct{ raw []byte } // ParseAllocColorCellsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseAllocColorCellsReply(raw []byte) (AllocColorCellsReply, bool) { if len(raw) < 32 { return AllocColorCellsReply{}, false } r := AllocColorCellsReply{raw: raw} off := 32 { n := int(r.PixelsLen()) if n < 0 || n > len(r.raw) { return AllocColorCellsReply{}, false } off += n * 4 } if off > len(r.raw) { return AllocColorCellsReply{}, false } { n := int(r.MasksLen()) if n < 0 || n > len(r.raw) { return AllocColorCellsReply{}, false } off += n * 4 } if off > len(r.raw) { return AllocColorCellsReply{}, false } if off > len(r.raw) { return AllocColorCellsReply{}, false } return r, true } func (r AllocColorCellsReply) Raw() []byte { return r.raw } func (r AllocColorCellsReply) PixelsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r AllocColorCellsReply) MasksLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } func (r AllocColorCellsReply) Pixels() Uint32List { off := 32 end := off + (int(r.PixelsLen()))*4 return Uint32List{b: r.raw[off:end:end]} } func (r AllocColorCellsReply) Masks() Uint32List { off := 32 { n := int(r.PixelsLen()) off += n * 4 } end := off + (int(r.MasksLen()))*4 return Uint32List{b: r.raw[off:end:end]} } // AllocColorPlanesReply is a zero-copy view over a AllocColorPlanes reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type AllocColorPlanesReply struct{ raw []byte } // ParseAllocColorPlanesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseAllocColorPlanesReply(raw []byte) (AllocColorPlanesReply, bool) { if len(raw) < 32 { return AllocColorPlanesReply{}, false } r := AllocColorPlanesReply{raw: raw} off := 32 { n := int(r.PixelsLen()) if n < 0 || n > len(r.raw) { return AllocColorPlanesReply{}, false } off += n * 4 } if off > len(r.raw) { return AllocColorPlanesReply{}, false } if off > len(r.raw) { return AllocColorPlanesReply{}, false } return r, true } func (r AllocColorPlanesReply) Raw() []byte { return r.raw } func (r AllocColorPlanesReply) PixelsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r AllocColorPlanesReply) RedMask() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) } func (r AllocColorPlanesReply) GreenMask() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) } func (r AllocColorPlanesReply) BlueMask() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[20:])) } func (r AllocColorPlanesReply) Pixels() Uint32List { off := 32 end := off + (int(r.PixelsLen()))*4 return Uint32List{b: r.raw[off:end:end]} } // QueryColorsReply is a zero-copy view over a QueryColors reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryColorsReply struct{ raw []byte } // ParseQueryColorsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryColorsReply(raw []byte) (QueryColorsReply, bool) { if len(raw) < 32 { return QueryColorsReply{}, false } r := QueryColorsReply{raw: raw} off := 32 { n := int(r.ColorsLen()) if n < 0 || n > len(r.raw) { return QueryColorsReply{}, false } off += n * 8 } if off > len(r.raw) { return QueryColorsReply{}, false } if off > len(r.raw) { return QueryColorsReply{}, false } return r, true } func (r QueryColorsReply) Raw() []byte { return r.raw } func (r QueryColorsReply) ColorsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r QueryColorsReply) Colors() RgbList { off := 32 end := off + (int(r.ColorsLen()))*8 return RgbList{b: r.raw[off:end:end]} } // LookupColorReply is a zero-copy view over a LookupColor reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type LookupColorReply struct{ raw []byte } // ParseLookupColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseLookupColorReply(raw []byte) (LookupColorReply, bool) { if len(raw) < 32 { return LookupColorReply{}, false } r := LookupColorReply{raw: raw} return r, true } func (r LookupColorReply) Raw() []byte { return r.raw } func (r LookupColorReply) ExactRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r LookupColorReply) ExactGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } func (r LookupColorReply) ExactBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } func (r LookupColorReply) VisualRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[14:])) } func (r LookupColorReply) VisualGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } func (r LookupColorReply) VisualBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) } // QueryBestSizeReply is a zero-copy view over a QueryBestSize reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryBestSizeReply struct{ raw []byte } // ParseQueryBestSizeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryBestSizeReply(raw []byte) (QueryBestSizeReply, bool) { if len(raw) < 32 { return QueryBestSizeReply{}, false } r := QueryBestSizeReply{raw: raw} return r, true } func (r QueryBestSizeReply) Raw() []byte { return r.raw } func (r QueryBestSizeReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r QueryBestSizeReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } // QueryExtensionReply is a zero-copy view over a QueryExtension reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type QueryExtensionReply struct{ raw []byte } // ParseQueryExtensionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseQueryExtensionReply(raw []byte) (QueryExtensionReply, bool) { if len(raw) < 32 { return QueryExtensionReply{}, false } r := QueryExtensionReply{raw: raw} return r, true } func (r QueryExtensionReply) Raw() []byte { return r.raw } func (r QueryExtensionReply) Present() bool { return (r.raw[8:][0] != 0) } func (r QueryExtensionReply) MajorOpcode() uint8 { return uint8(r.raw[9:][0]) } func (r QueryExtensionReply) FirstEvent() uint8 { return uint8(r.raw[10:][0]) } func (r QueryExtensionReply) FirstError() uint8 { return uint8(r.raw[11:][0]) } // ListExtensionsReply is a zero-copy view over a ListExtensions reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type ListExtensionsReply struct{ raw []byte } // ParseListExtensionsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseListExtensionsReply(raw []byte) (ListExtensionsReply, bool) { if len(raw) < 32 { return ListExtensionsReply{}, false } r := ListExtensionsReply{raw: raw} off := 32 { n := int(r.NamesLen()) if off > len(r.raw) || n < 0 || n > len(r.raw) { return ListExtensionsReply{}, false } it := NewStrIter(r.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return ListExtensionsReply{}, false } } if off > len(r.raw) { return ListExtensionsReply{}, false } return r, true } func (r ListExtensionsReply) Raw() []byte { return r.raw } func (r ListExtensionsReply) NamesLen() uint8 { return uint8(r.raw[1:][0]) } func (r ListExtensionsReply) Names() StrIter { off := 32 return NewStrIter(r.raw[off:], int(r.NamesLen())) } // GetKeyboardMappingReply is a zero-copy view over a GetKeyboardMapping reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetKeyboardMappingReply struct{ raw []byte } // ParseGetKeyboardMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetKeyboardMappingReply(raw []byte) (GetKeyboardMappingReply, bool) { if len(raw) < 32 { return GetKeyboardMappingReply{}, false } r := GetKeyboardMappingReply{raw: raw} off := 32 { n := int(binary.LittleEndian.Uint32(r.raw[4:])) if n < 0 || n > len(r.raw) { return GetKeyboardMappingReply{}, false } off += n * 4 } if off > len(r.raw) { return GetKeyboardMappingReply{}, false } if off > len(r.raw) { return GetKeyboardMappingReply{}, false } return r, true } func (r GetKeyboardMappingReply) Raw() []byte { return r.raw } func (r GetKeyboardMappingReply) KeysymsPerKeycode() byte { return byte(r.raw[1:][0]) } func (r GetKeyboardMappingReply) Keysyms() KeysymList { off := 32 end := off + (int(binary.LittleEndian.Uint32(r.raw[4:])))*4 return KeysymList{b: r.raw[off:end:end]} } // GetKeyboardControlReply is a zero-copy view over a GetKeyboardControl reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetKeyboardControlReply struct{ raw []byte } // ParseGetKeyboardControlReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetKeyboardControlReply(raw []byte) (GetKeyboardControlReply, bool) { if len(raw) < 52 { return GetKeyboardControlReply{}, false } r := GetKeyboardControlReply{raw: raw} return r, true } func (r GetKeyboardControlReply) Raw() []byte { return r.raw } func (r GetKeyboardControlReply) GlobalAutoRepeat() AutoRepeatMode { return AutoRepeatMode(r.raw[1:][0]) } func (r GetKeyboardControlReply) LedMask() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } func (r GetKeyboardControlReply) KeyClickPercent() uint8 { return uint8(r.raw[12:][0]) } func (r GetKeyboardControlReply) BellPercent() uint8 { return uint8(r.raw[13:][0]) } func (r GetKeyboardControlReply) BellPitch() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[14:])) } func (r GetKeyboardControlReply) BellDuration() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } func (r GetKeyboardControlReply) AutoRepeats() []byte { off := 20 end := off + 32 return r.raw[off:end:end] } // GetPointerControlReply is a zero-copy view over a GetPointerControl reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetPointerControlReply struct{ raw []byte } // ParseGetPointerControlReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetPointerControlReply(raw []byte) (GetPointerControlReply, bool) { if len(raw) < 32 { return GetPointerControlReply{}, false } r := GetPointerControlReply{raw: raw} return r, true } func (r GetPointerControlReply) Raw() []byte { return r.raw } func (r GetPointerControlReply) AccelerationNumerator() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r GetPointerControlReply) AccelerationDenominator() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } func (r GetPointerControlReply) Threshold() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } // GetScreenSaverReply is a zero-copy view over a GetScreenSaver reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetScreenSaverReply struct{ raw []byte } // ParseGetScreenSaverReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetScreenSaverReply(raw []byte) (GetScreenSaverReply, bool) { if len(raw) < 32 { return GetScreenSaverReply{}, false } r := GetScreenSaverReply{raw: raw} return r, true } func (r GetScreenSaverReply) Raw() []byte { return r.raw } func (r GetScreenSaverReply) Timeout() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r GetScreenSaverReply) Interval() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } func (r GetScreenSaverReply) PreferBlanking() Blanking { return Blanking(r.raw[12:][0]) } func (r GetScreenSaverReply) AllowExposures() Exposures { return Exposures(r.raw[13:][0]) } // ListHostsReply is a zero-copy view over a ListHosts reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type ListHostsReply struct{ raw []byte } // ParseListHostsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseListHostsReply(raw []byte) (ListHostsReply, bool) { if len(raw) < 32 { return ListHostsReply{}, false } r := ListHostsReply{raw: raw} off := 32 { n := int(r.HostsLen()) if off > len(r.raw) || n < 0 || n > len(r.raw) { return ListHostsReply{}, false } it := NewHostIter(r.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return ListHostsReply{}, false } } if off > len(r.raw) { return ListHostsReply{}, false } return r, true } func (r ListHostsReply) Raw() []byte { return r.raw } func (r ListHostsReply) Mode() AccessControl { return AccessControl(r.raw[1:][0]) } func (r ListHostsReply) HostsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } func (r ListHostsReply) Hosts() HostIter { off := 32 return NewHostIter(r.raw[off:], int(r.HostsLen())) } // SetPointerMappingReply is a zero-copy view over a SetPointerMapping reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type SetPointerMappingReply struct{ raw []byte } // ParseSetPointerMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseSetPointerMappingReply(raw []byte) (SetPointerMappingReply, bool) { if len(raw) < 32 { return SetPointerMappingReply{}, false } r := SetPointerMappingReply{raw: raw} return r, true } func (r SetPointerMappingReply) Raw() []byte { return r.raw } func (r SetPointerMappingReply) Status() MappingStatus { return MappingStatus(r.raw[1:][0]) } // GetPointerMappingReply is a zero-copy view over a GetPointerMapping reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetPointerMappingReply struct{ raw []byte } // ParseGetPointerMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetPointerMappingReply(raw []byte) (GetPointerMappingReply, bool) { if len(raw) < 32 { return GetPointerMappingReply{}, false } r := GetPointerMappingReply{raw: raw} off := 32 { n := int(r.MapLen()) if n < 0 || n > len(r.raw) { return GetPointerMappingReply{}, false } off += n * 1 } if off > len(r.raw) { return GetPointerMappingReply{}, false } if off > len(r.raw) { return GetPointerMappingReply{}, false } return r, true } func (r GetPointerMappingReply) Raw() []byte { return r.raw } func (r GetPointerMappingReply) MapLen() uint8 { return uint8(r.raw[1:][0]) } func (r GetPointerMappingReply) Map() []byte { off := 32 end := off + int(r.MapLen()) return r.raw[off:end:end] } // SetModifierMappingReply is a zero-copy view over a SetModifierMapping reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type SetModifierMappingReply struct{ raw []byte } // ParseSetModifierMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseSetModifierMappingReply(raw []byte) (SetModifierMappingReply, bool) { if len(raw) < 32 { return SetModifierMappingReply{}, false } r := SetModifierMappingReply{raw: raw} return r, true } func (r SetModifierMappingReply) Raw() []byte { return r.raw } func (r SetModifierMappingReply) Status() MappingStatus { return MappingStatus(r.raw[1:][0]) } // GetModifierMappingReply is a zero-copy view over a GetModifierMapping reply; offsets count from reply byte 0. // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. type GetModifierMappingReply struct{ raw []byte } // ParseGetModifierMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. func ParseGetModifierMappingReply(raw []byte) (GetModifierMappingReply, bool) { if len(raw) < 32 { return GetModifierMappingReply{}, false } r := GetModifierMappingReply{raw: raw} off := 32 { n := (int(r.KeycodesPerModifier()) * 8) if n < 0 || n > len(r.raw) { return GetModifierMappingReply{}, false } off += n * 1 } if off > len(r.raw) { return GetModifierMappingReply{}, false } if off > len(r.raw) { return GetModifierMappingReply{}, false } return r, true } func (r GetModifierMappingReply) Raw() []byte { return r.raw } func (r GetModifierMappingReply) KeycodesPerModifier() uint8 { return uint8(r.raw[1:][0]) } func (r GetModifierMappingReply) Keycodes() KeycodeList { off := 32 end := off + (int(r.KeycodesPerModifier())*8)*1 return KeycodeList{b: r.raw[off:end:end]} } // DepthView is a zero-copy view over one wire-encoded Depth, yielded by DepthIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type DepthView struct{ raw []byte } func (v DepthView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v DepthView) Size() int { return len(v.raw) } func sizeDepth(p []byte) int { if len(p) < 8 { return -1 } v := DepthView{raw: p} _ = v off := 8 { n := int(v.VisualsLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 24 } if off > len(v.raw) { return -1 } if off > len(v.raw) { return -1 } return off } func (v DepthView) Depth() uint8 { return uint8(v.raw[0:][0]) } func (v DepthView) VisualsLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } func (v DepthView) Visuals() VisualtypeList { off := 8 end := off + (int(v.VisualsLen()))*24 return VisualtypeList{b: v.raw[off:end:end]} } // DepthIter walks n consecutive Depth elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type DepthIter struct { b []byte n int v DepthView err bool } // NewDepthIter iterates n elements encoded at the start of b. func NewDepthIter(b []byte, n int) DepthIter { return DepthIter{b: b, n: n} } func (it *DepthIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeDepth(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = DepthView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *DepthIter) Value() DepthView { return it.v } func (it *DepthIter) Err() bool { return it.err } // ScreenView is a zero-copy view over one wire-encoded Screen, yielded by ScreenIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type ScreenView struct{ raw []byte } func (v ScreenView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v ScreenView) Size() int { return len(v.raw) } func sizeScreen(p []byte) int { if len(p) < 40 { return -1 } v := ScreenView{raw: p} _ = v off := 40 { n := int(v.AllowedDepthsLen()) if off > len(v.raw) || n < 0 || n > len(v.raw) { return -1 } it := NewDepthIter(v.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return -1 } } if off > len(v.raw) { return -1 } return off } func (v ScreenView) Root() Window { return Window(binary.LittleEndian.Uint32(v.raw[0:])) } func (v ScreenView) DefaultColormap() Colormap { return Colormap(binary.LittleEndian.Uint32(v.raw[4:])) } func (v ScreenView) WhitePixel() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) } func (v ScreenView) BlackPixel() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[12:])) } func (v ScreenView) CurrentInputMasks() EventMask { return EventMask(binary.LittleEndian.Uint32(v.raw[16:])) } func (v ScreenView) WidthInPixels() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[20:])) } func (v ScreenView) HeightInPixels() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[22:])) } func (v ScreenView) WidthInMillimeters() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[24:])) } func (v ScreenView) HeightInMillimeters() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[26:])) } func (v ScreenView) MinInstalledMaps() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[28:])) } func (v ScreenView) MaxInstalledMaps() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[30:])) } func (v ScreenView) RootVisual() Visualid { return Visualid(binary.LittleEndian.Uint32(v.raw[32:])) } func (v ScreenView) BackingStores() BackingStore { return BackingStore(v.raw[36:][0]) } func (v ScreenView) SaveUnders() bool { return (v.raw[37:][0] != 0) } func (v ScreenView) RootDepth() uint8 { return uint8(v.raw[38:][0]) } func (v ScreenView) AllowedDepthsLen() uint8 { return uint8(v.raw[39:][0]) } func (v ScreenView) AllowedDepths() DepthIter { off := 40 return NewDepthIter(v.raw[off:], int(v.AllowedDepthsLen())) } // ScreenIter walks n consecutive Screen elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type ScreenIter struct { b []byte n int v ScreenView err bool } // NewScreenIter iterates n elements encoded at the start of b. func NewScreenIter(b []byte, n int) ScreenIter { return ScreenIter{b: b, n: n} } func (it *ScreenIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeScreen(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = ScreenView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *ScreenIter) Value() ScreenView { return it.v } func (it *ScreenIter) Err() bool { return it.err } // SetupRequestView is a zero-copy view over one wire-encoded SetupRequest, yielded by SetupRequestIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type SetupRequestView struct{ raw []byte } func (v SetupRequestView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v SetupRequestView) Size() int { return len(v.raw) } func sizeSetupRequest(p []byte) int { if len(p) < 12 { return -1 } v := SetupRequestView{raw: p} _ = v off := 12 { n := int(v.AuthorizationProtocolNameLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } off = (off + 3) &^ 3 { n := int(v.AuthorizationProtocolDataLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } off = (off + 3) &^ 3 if off > len(v.raw) { return -1 } return off } func (v SetupRequestView) ByteOrder() uint8 { return uint8(v.raw[0:][0]) } func (v SetupRequestView) ProtocolMajorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } func (v SetupRequestView) ProtocolMinorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[4:])) } func (v SetupRequestView) AuthorizationProtocolNameLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } func (v SetupRequestView) AuthorizationProtocolDataLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[8:])) } func (v SetupRequestView) AuthorizationProtocolName() []byte { off := 12 end := off + int(v.AuthorizationProtocolNameLen()) return v.raw[off:end:end] } func (v SetupRequestView) AuthorizationProtocolData() []byte { off := 12 { n := int(v.AuthorizationProtocolNameLen()) off += n * 1 } off = (off + 3) &^ 3 end := off + int(v.AuthorizationProtocolDataLen()) return v.raw[off:end:end] } // SetupRequestIter walks n consecutive SetupRequest elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type SetupRequestIter struct { b []byte n int v SetupRequestView err bool } // NewSetupRequestIter iterates n elements encoded at the start of b. func NewSetupRequestIter(b []byte, n int) SetupRequestIter { return SetupRequestIter{b: b, n: n} } func (it *SetupRequestIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeSetupRequest(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = SetupRequestView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *SetupRequestIter) Value() SetupRequestView { return it.v } func (it *SetupRequestIter) Err() bool { return it.err } // SetupFailedView is a zero-copy view over one wire-encoded SetupFailed, yielded by SetupFailedIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type SetupFailedView struct{ raw []byte } func (v SetupFailedView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v SetupFailedView) Size() int { return len(v.raw) } func sizeSetupFailed(p []byte) int { if len(p) < 8 { return -1 } v := SetupFailedView{raw: p} _ = v off := 8 { n := int(v.ReasonLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } if off > len(v.raw) { return -1 } return off } func (v SetupFailedView) Status() uint8 { return uint8(v.raw[0:][0]) } func (v SetupFailedView) ReasonLen() uint8 { return uint8(v.raw[1:][0]) } func (v SetupFailedView) ProtocolMajorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } func (v SetupFailedView) ProtocolMinorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[4:])) } func (v SetupFailedView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } func (v SetupFailedView) Reason() []byte { off := 8 end := off + int(v.ReasonLen()) return v.raw[off:end:end] } // SetupFailedIter walks n consecutive SetupFailed elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type SetupFailedIter struct { b []byte n int v SetupFailedView err bool } // NewSetupFailedIter iterates n elements encoded at the start of b. func NewSetupFailedIter(b []byte, n int) SetupFailedIter { return SetupFailedIter{b: b, n: n} } func (it *SetupFailedIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeSetupFailed(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = SetupFailedView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *SetupFailedIter) Value() SetupFailedView { return it.v } func (it *SetupFailedIter) Err() bool { return it.err } // SetupAuthenticateView is a zero-copy view over one wire-encoded SetupAuthenticate, yielded by SetupAuthenticateIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type SetupAuthenticateView struct{ raw []byte } func (v SetupAuthenticateView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v SetupAuthenticateView) Size() int { return len(v.raw) } func sizeSetupAuthenticate(p []byte) int { if len(p) < 8 { return -1 } v := SetupAuthenticateView{raw: p} _ = v off := 8 { n := (int(v.Length()) * 4) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } if off > len(v.raw) { return -1 } return off } func (v SetupAuthenticateView) Status() uint8 { return uint8(v.raw[0:][0]) } func (v SetupAuthenticateView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } func (v SetupAuthenticateView) Reason() []byte { off := 8 end := off + (int(v.Length()) * 4) return v.raw[off:end:end] } // SetupAuthenticateIter walks n consecutive SetupAuthenticate elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type SetupAuthenticateIter struct { b []byte n int v SetupAuthenticateView err bool } // NewSetupAuthenticateIter iterates n elements encoded at the start of b. func NewSetupAuthenticateIter(b []byte, n int) SetupAuthenticateIter { return SetupAuthenticateIter{b: b, n: n} } func (it *SetupAuthenticateIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeSetupAuthenticate(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = SetupAuthenticateView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *SetupAuthenticateIter) Value() SetupAuthenticateView { return it.v } func (it *SetupAuthenticateIter) Err() bool { return it.err } // SetupView is a zero-copy view over one wire-encoded Setup, yielded by SetupIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type SetupView struct{ raw []byte } func (v SetupView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v SetupView) Size() int { return len(v.raw) } func sizeSetup(p []byte) int { if len(p) < 40 { return -1 } v := SetupView{raw: p} _ = v off := 40 { n := int(v.VendorLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } off = (off + 3) &^ 3 { n := int(v.PixmapFormatsLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 8 } if off > len(v.raw) { return -1 } { n := int(v.RootsLen()) if off > len(v.raw) || n < 0 || n > len(v.raw) { return -1 } it := NewScreenIter(v.raw[off:], n) for it.Next() { off += it.Value().Size() } if it.Err() { return -1 } } if off > len(v.raw) { return -1 } return off } func (v SetupView) Status() uint8 { return uint8(v.raw[0:][0]) } func (v SetupView) ProtocolMajorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } func (v SetupView) ProtocolMinorVersion() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[4:])) } func (v SetupView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } func (v SetupView) ReleaseNumber() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) } func (v SetupView) ResourceIdBase() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[12:])) } func (v SetupView) ResourceIdMask() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[16:])) } func (v SetupView) MotionBufferSize() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[20:])) } func (v SetupView) VendorLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[24:])) } func (v SetupView) MaximumRequestLength() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[26:])) } func (v SetupView) RootsLen() uint8 { return uint8(v.raw[28:][0]) } func (v SetupView) PixmapFormatsLen() uint8 { return uint8(v.raw[29:][0]) } func (v SetupView) ImageByteOrder() ImageOrder { return ImageOrder(v.raw[30:][0]) } func (v SetupView) BitmapFormatBitOrder() ImageOrder { return ImageOrder(v.raw[31:][0]) } func (v SetupView) BitmapFormatScanlineUnit() uint8 { return uint8(v.raw[32:][0]) } func (v SetupView) BitmapFormatScanlinePad() uint8 { return uint8(v.raw[33:][0]) } func (v SetupView) MinKeycode() Keycode { return Keycode(v.raw[34:][0]) } func (v SetupView) MaxKeycode() Keycode { return Keycode(v.raw[35:][0]) } func (v SetupView) Vendor() []byte { off := 40 end := off + int(v.VendorLen()) return v.raw[off:end:end] } func (v SetupView) PixmapFormats() FormatList { off := 40 { n := int(v.VendorLen()) off += n * 1 } off = (off + 3) &^ 3 end := off + (int(v.PixmapFormatsLen()))*8 return FormatList{b: v.raw[off:end:end]} } func (v SetupView) Roots() ScreenIter { off := 40 { n := int(v.VendorLen()) off += n * 1 } off = (off + 3) &^ 3 { n := int(v.PixmapFormatsLen()) off += n * 8 } return NewScreenIter(v.raw[off:], int(v.RootsLen())) } // SetupIter walks n consecutive Setup elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type SetupIter struct { b []byte n int v SetupView err bool } // NewSetupIter iterates n elements encoded at the start of b. func NewSetupIter(b []byte, n int) SetupIter { return SetupIter{b: b, n: n} } func (it *SetupIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeSetup(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = SetupView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *SetupIter) Value() SetupView { return it.v } func (it *SetupIter) Err() bool { return it.err } // StrView is a zero-copy view over one wire-encoded Str, yielded by StrIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type StrView struct{ raw []byte } func (v StrView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v StrView) Size() int { return len(v.raw) } func sizeStr(p []byte) int { if len(p) < 1 { return -1 } v := StrView{raw: p} _ = v off := 1 { n := int(v.NameLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } if off > len(v.raw) { return -1 } return off } func (v StrView) NameLen() uint8 { return uint8(v.raw[0:][0]) } func (v StrView) Name() []byte { off := 1; end := off + int(v.NameLen()); return v.raw[off:end:end] } // StrIter walks n consecutive Str elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type StrIter struct { b []byte n int v StrView err bool } // NewStrIter iterates n elements encoded at the start of b. func NewStrIter(b []byte, n int) StrIter { return StrIter{b: b, n: n} } func (it *StrIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeStr(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = StrView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *StrIter) Value() StrView { return it.v } func (it *StrIter) Err() bool { return it.err } // HostView is a zero-copy view over one wire-encoded Host, yielded by HostIter. // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. type HostView struct{ raw []byte } func (v HostView) Raw() []byte { return v.raw } // Size is the element's wire size, including trailing alignment. func (v HostView) Size() int { return len(v.raw) } func sizeHost(p []byte) int { if len(p) < 4 { return -1 } v := HostView{raw: p} _ = v off := 4 { n := int(v.AddressLen()) if n < 0 || n > len(v.raw) { return -1 } off += n * 1 } if off > len(v.raw) { return -1 } off = (off + 3) &^ 3 if off > len(v.raw) { return -1 } return off } func (v HostView) Family() Family { return Family(v.raw[0:][0]) } func (v HostView) AddressLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } func (v HostView) Address() []byte { off := 4 end := off + int(v.AddressLen()) return v.raw[off:end:end] } // HostIter walks n consecutive Host elements; Err reports a malformed length. // It shares the lifetime of the bytes it walks. type HostIter struct { b []byte n int v HostView err bool } // NewHostIter iterates n elements encoded at the start of b. func NewHostIter(b []byte, n int) HostIter { return HostIter{b: b, n: n} } func (it *HostIter) Next() bool { if it.n <= 0 || it.err { return false } s := sizeHost(it.b) if s < 0 { it.err = true it.n = 0 return false } it.v = HostView{raw: it.b[:s:s]} it.b = it.b[s:] it.n-- return true } func (it *HostIter) Value() HostView { return it.v } func (it *HostIter) Err() bool { return it.err } // AtomList is a borrowed view over a wire list of Atom. It shares the lifetime of the bytes it was taken from; copy what you keep. type AtomList struct{ b []byte } func (l AtomList) Len() int { return len(l.b) / 4 } func (l AtomList) At(i int) Atom { return Atom(binary.LittleEndian.Uint32(l.b[i*4:])) } // CharinfoList is a borrowed view over a wire list of Charinfo. It shares the lifetime of the bytes it was taken from; copy what you keep. type CharinfoList struct{ b []byte } func (l CharinfoList) Len() int { return len(l.b) / 12 } func (l CharinfoList) At(i int) Charinfo { return GetCharinfo(l.b[i*12:]) } // ColormapList is a borrowed view over a wire list of Colormap. It shares the lifetime of the bytes it was taken from; copy what you keep. type ColormapList struct{ b []byte } func (l ColormapList) Len() int { return len(l.b) / 4 } func (l ColormapList) At(i int) Colormap { return Colormap(binary.LittleEndian.Uint32(l.b[i*4:])) } // FontpropList is a borrowed view over a wire list of Fontprop. It shares the lifetime of the bytes it was taken from; copy what you keep. type FontpropList struct{ b []byte } func (l FontpropList) Len() int { return len(l.b) / 8 } func (l FontpropList) At(i int) Fontprop { return GetFontprop(l.b[i*8:]) } // FormatList is a borrowed view over a wire list of Format. It shares the lifetime of the bytes it was taken from; copy what you keep. type FormatList struct{ b []byte } func (l FormatList) Len() int { return len(l.b) / 8 } func (l FormatList) At(i int) Format { return GetFormat(l.b[i*8:]) } // KeycodeList is a borrowed view over a wire list of Keycode. It shares the lifetime of the bytes it was taken from; copy what you keep. type KeycodeList struct{ b []byte } func (l KeycodeList) Len() int { return len(l.b) / 1 } func (l KeycodeList) At(i int) Keycode { return Keycode(l.b[i*1:][0]) } // KeysymList is a borrowed view over a wire list of Keysym. It shares the lifetime of the bytes it was taken from; copy what you keep. type KeysymList struct{ b []byte } func (l KeysymList) Len() int { return len(l.b) / 4 } func (l KeysymList) At(i int) Keysym { return Keysym(binary.LittleEndian.Uint32(l.b[i*4:])) } // RgbList is a borrowed view over a wire list of Rgb. It shares the lifetime of the bytes it was taken from; copy what you keep. type RgbList struct{ b []byte } func (l RgbList) Len() int { return len(l.b) / 8 } func (l RgbList) At(i int) Rgb { return GetRgb(l.b[i*8:]) } // TimecoordList is a borrowed view over a wire list of Timecoord. It shares the lifetime of the bytes it was taken from; copy what you keep. type TimecoordList struct{ b []byte } func (l TimecoordList) Len() int { return len(l.b) / 8 } func (l TimecoordList) At(i int) Timecoord { return GetTimecoord(l.b[i*8:]) } // Uint32List is a borrowed view over a wire list of uint32. It shares the lifetime of the bytes it was taken from; copy what you keep. type Uint32List struct{ b []byte } func (l Uint32List) Len() int { return len(l.b) / 4 } func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) } // VisualtypeList is a borrowed view over a wire list of Visualtype. It shares the lifetime of the bytes it was taken from; copy what you keep. type VisualtypeList struct{ b []byte } func (l VisualtypeList) Len() int { return len(l.b) / 24 } func (l VisualtypeList) At(i int) Visualtype { return GetVisualtype(l.b[i*24:]) } // WindowList is a borrowed view over a wire list of Window. It shares the lifetime of the bytes it was taken from; copy what you keep. type WindowList struct{ b []byte } func (l WindowList) Len() int { return len(l.b) / 4 } func (l WindowList) At(i int) Window { return Window(binary.LittleEndian.Uint32(l.b[i*4:])) }