1// Code generated by xtgen; DO NOT EDIT.
2package xproto
3
4import "encoding/binary"
5
6// GetWindowAttributesReply is a zero-copy view over a GetWindowAttributes reply; offsets count from reply byte 0.
7// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
8type GetWindowAttributesReply struct{ raw []byte }
9
10// ParseGetWindowAttributesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
11func ParseGetWindowAttributesReply(raw []byte) (GetWindowAttributesReply, bool) {
12 if len(raw) < 44 {
13 return GetWindowAttributesReply{}, false
14 }
15 r := GetWindowAttributesReply{raw: raw}
16 return r, true
17}
18func (r GetWindowAttributesReply) Raw() []byte { return r.raw }
19func (r GetWindowAttributesReply) BackingStore() BackingStore { return BackingStore(r.raw[1:][0]) }
20func (r GetWindowAttributesReply) Visual() Visualid {
21 return Visualid(binary.LittleEndian.Uint32(r.raw[8:]))
22}
23func (r GetWindowAttributesReply) Class() WindowClass {
24 return WindowClass(binary.LittleEndian.Uint16(r.raw[12:]))
25}
26func (r GetWindowAttributesReply) BitGravity() Gravity { return Gravity(r.raw[14:][0]) }
27func (r GetWindowAttributesReply) WinGravity() Gravity { return Gravity(r.raw[15:][0]) }
28func (r GetWindowAttributesReply) BackingPlanes() uint32 {
29 return uint32(binary.LittleEndian.Uint32(r.raw[16:]))
30}
31func (r GetWindowAttributesReply) BackingPixel() uint32 {
32 return uint32(binary.LittleEndian.Uint32(r.raw[20:]))
33}
34func (r GetWindowAttributesReply) SaveUnder() bool { return (r.raw[24:][0] != 0) }
35func (r GetWindowAttributesReply) MapIsInstalled() bool { return (r.raw[25:][0] != 0) }
36func (r GetWindowAttributesReply) MapState() MapState { return MapState(r.raw[26:][0]) }
37func (r GetWindowAttributesReply) OverrideRedirect() bool { return (r.raw[27:][0] != 0) }
38func (r GetWindowAttributesReply) Colormap() Colormap {
39 return Colormap(binary.LittleEndian.Uint32(r.raw[28:]))
40}
41func (r GetWindowAttributesReply) AllEventMasks() EventMask {
42 return EventMask(binary.LittleEndian.Uint32(r.raw[32:]))
43}
44func (r GetWindowAttributesReply) YourEventMask() EventMask {
45 return EventMask(binary.LittleEndian.Uint32(r.raw[36:]))
46}
47func (r GetWindowAttributesReply) DoNotPropagateMask() EventMask {
48 return EventMask(binary.LittleEndian.Uint16(r.raw[40:]))
49}
50
51// GetGeometryReply is a zero-copy view over a GetGeometry reply; offsets count from reply byte 0.
52// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
53type GetGeometryReply struct{ raw []byte }
54
55// ParseGetGeometryReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
56func ParseGetGeometryReply(raw []byte) (GetGeometryReply, bool) {
57 if len(raw) < 32 {
58 return GetGeometryReply{}, false
59 }
60 r := GetGeometryReply{raw: raw}
61 return r, true
62}
63func (r GetGeometryReply) Raw() []byte { return r.raw }
64func (r GetGeometryReply) Depth() uint8 { return uint8(r.raw[1:][0]) }
65func (r GetGeometryReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) }
66func (r GetGeometryReply) X() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) }
67func (r GetGeometryReply) Y() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) }
68func (r GetGeometryReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) }
69func (r GetGeometryReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) }
70func (r GetGeometryReply) BorderWidth() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[20:])) }
71
72// QueryTreeReply is a zero-copy view over a QueryTree reply; offsets count from reply byte 0.
73// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
74type QueryTreeReply struct{ raw []byte }
75
76// ParseQueryTreeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
77func ParseQueryTreeReply(raw []byte) (QueryTreeReply, bool) {
78 if len(raw) < 32 {
79 return QueryTreeReply{}, false
80 }
81 r := QueryTreeReply{raw: raw}
82 off := 32
83 {
84 n := int(r.ChildrenLen())
85 if n < 0 || n > len(r.raw) {
86 return QueryTreeReply{}, false
87 }
88 off += n * 4
89 }
90 if off > len(r.raw) {
91 return QueryTreeReply{}, false
92 }
93 if off > len(r.raw) {
94 return QueryTreeReply{}, false
95 }
96 return r, true
97}
98func (r QueryTreeReply) Raw() []byte { return r.raw }
99func (r QueryTreeReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) }
100func (r QueryTreeReply) Parent() Window { return Window(binary.LittleEndian.Uint32(r.raw[12:])) }
101func (r QueryTreeReply) ChildrenLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) }
102func (r QueryTreeReply) Children() WindowList {
103 off := 32
104 end := off + (int(r.ChildrenLen()))*4
105 return WindowList{b: r.raw[off:end:end]}
106}
107
108// InternAtomReply is a zero-copy view over a InternAtom reply; offsets count from reply byte 0.
109// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
110type InternAtomReply struct{ raw []byte }
111
112// ParseInternAtomReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
113func ParseInternAtomReply(raw []byte) (InternAtomReply, bool) {
114 if len(raw) < 32 {
115 return InternAtomReply{}, false
116 }
117 r := InternAtomReply{raw: raw}
118 return r, true
119}
120func (r InternAtomReply) Raw() []byte { return r.raw }
121func (r InternAtomReply) Atom() Atom { return Atom(binary.LittleEndian.Uint32(r.raw[8:])) }
122
123// GetAtomNameReply is a zero-copy view over a GetAtomName reply; offsets count from reply byte 0.
124// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
125type GetAtomNameReply struct{ raw []byte }
126
127// ParseGetAtomNameReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
128func ParseGetAtomNameReply(raw []byte) (GetAtomNameReply, bool) {
129 if len(raw) < 32 {
130 return GetAtomNameReply{}, false
131 }
132 r := GetAtomNameReply{raw: raw}
133 off := 32
134 {
135 n := int(r.NameLen())
136 if n < 0 || n > len(r.raw) {
137 return GetAtomNameReply{}, false
138 }
139 off += n * 1
140 }
141 if off > len(r.raw) {
142 return GetAtomNameReply{}, false
143 }
144 if off > len(r.raw) {
145 return GetAtomNameReply{}, false
146 }
147 return r, true
148}
149func (r GetAtomNameReply) Raw() []byte { return r.raw }
150func (r GetAtomNameReply) NameLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
151func (r GetAtomNameReply) Name() []byte {
152 off := 32
153 end := off + int(r.NameLen())
154 return r.raw[off:end:end]
155}
156
157// GetPropertyReply is a zero-copy view over a GetProperty reply; offsets count from reply byte 0.
158// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
159type GetPropertyReply struct{ raw []byte }
160
161// ParseGetPropertyReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
162func ParseGetPropertyReply(raw []byte) (GetPropertyReply, bool) {
163 if len(raw) < 32 {
164 return GetPropertyReply{}, false
165 }
166 r := GetPropertyReply{raw: raw}
167 off := 32
168 {
169 n := (int(r.ValueLen()) * (int(r.Format()) / 8))
170 if n < 0 || n > len(r.raw) {
171 return GetPropertyReply{}, false
172 }
173 off += n * 1
174 }
175 if off > len(r.raw) {
176 return GetPropertyReply{}, false
177 }
178 if off > len(r.raw) {
179 return GetPropertyReply{}, false
180 }
181 return r, true
182}
183func (r GetPropertyReply) Raw() []byte { return r.raw }
184func (r GetPropertyReply) Format() uint8 { return uint8(r.raw[1:][0]) }
185func (r GetPropertyReply) Type() Atom { return Atom(binary.LittleEndian.Uint32(r.raw[8:])) }
186func (r GetPropertyReply) BytesAfter() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) }
187func (r GetPropertyReply) ValueLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) }
188func (r GetPropertyReply) Value() []byte {
189 off := 32
190 end := off + (int(r.ValueLen()) * (int(r.Format()) / 8))
191 return r.raw[off:end:end]
192}
193
194// ListPropertiesReply is a zero-copy view over a ListProperties reply; offsets count from reply byte 0.
195// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
196type ListPropertiesReply struct{ raw []byte }
197
198// ParseListPropertiesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
199func ParseListPropertiesReply(raw []byte) (ListPropertiesReply, bool) {
200 if len(raw) < 32 {
201 return ListPropertiesReply{}, false
202 }
203 r := ListPropertiesReply{raw: raw}
204 off := 32
205 {
206 n := int(r.AtomsLen())
207 if n < 0 || n > len(r.raw) {
208 return ListPropertiesReply{}, false
209 }
210 off += n * 4
211 }
212 if off > len(r.raw) {
213 return ListPropertiesReply{}, false
214 }
215 if off > len(r.raw) {
216 return ListPropertiesReply{}, false
217 }
218 return r, true
219}
220func (r ListPropertiesReply) Raw() []byte { return r.raw }
221func (r ListPropertiesReply) AtomsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
222func (r ListPropertiesReply) Atoms() AtomList {
223 off := 32
224 end := off + (int(r.AtomsLen()))*4
225 return AtomList{b: r.raw[off:end:end]}
226}
227
228// GetSelectionOwnerReply is a zero-copy view over a GetSelectionOwner reply; offsets count from reply byte 0.
229// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
230type GetSelectionOwnerReply struct{ raw []byte }
231
232// ParseGetSelectionOwnerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
233func ParseGetSelectionOwnerReply(raw []byte) (GetSelectionOwnerReply, bool) {
234 if len(raw) < 32 {
235 return GetSelectionOwnerReply{}, false
236 }
237 r := GetSelectionOwnerReply{raw: raw}
238 return r, true
239}
240func (r GetSelectionOwnerReply) Raw() []byte { return r.raw }
241func (r GetSelectionOwnerReply) Owner() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) }
242
243// GrabPointerReply is a zero-copy view over a GrabPointer reply; offsets count from reply byte 0.
244// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
245type GrabPointerReply struct{ raw []byte }
246
247// ParseGrabPointerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
248func ParseGrabPointerReply(raw []byte) (GrabPointerReply, bool) {
249 if len(raw) < 32 {
250 return GrabPointerReply{}, false
251 }
252 r := GrabPointerReply{raw: raw}
253 return r, true
254}
255func (r GrabPointerReply) Raw() []byte { return r.raw }
256func (r GrabPointerReply) Status() GrabStatus { return GrabStatus(r.raw[1:][0]) }
257
258// GrabKeyboardReply is a zero-copy view over a GrabKeyboard reply; offsets count from reply byte 0.
259// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
260type GrabKeyboardReply struct{ raw []byte }
261
262// ParseGrabKeyboardReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
263func ParseGrabKeyboardReply(raw []byte) (GrabKeyboardReply, bool) {
264 if len(raw) < 32 {
265 return GrabKeyboardReply{}, false
266 }
267 r := GrabKeyboardReply{raw: raw}
268 return r, true
269}
270func (r GrabKeyboardReply) Raw() []byte { return r.raw }
271func (r GrabKeyboardReply) Status() GrabStatus { return GrabStatus(r.raw[1:][0]) }
272
273// QueryPointerReply is a zero-copy view over a QueryPointer reply; offsets count from reply byte 0.
274// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
275type QueryPointerReply struct{ raw []byte }
276
277// ParseQueryPointerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
278func ParseQueryPointerReply(raw []byte) (QueryPointerReply, bool) {
279 if len(raw) < 32 {
280 return QueryPointerReply{}, false
281 }
282 r := QueryPointerReply{raw: raw}
283 return r, true
284}
285func (r QueryPointerReply) Raw() []byte { return r.raw }
286func (r QueryPointerReply) SameScreen() bool { return (r.raw[1:][0] != 0) }
287func (r QueryPointerReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) }
288func (r QueryPointerReply) Child() Window { return Window(binary.LittleEndian.Uint32(r.raw[12:])) }
289func (r QueryPointerReply) RootX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[16:])) }
290func (r QueryPointerReply) RootY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[18:])) }
291func (r QueryPointerReply) WinX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[20:])) }
292func (r QueryPointerReply) WinY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[22:])) }
293func (r QueryPointerReply) Mask() KeyButMask {
294 return KeyButMask(binary.LittleEndian.Uint16(r.raw[24:]))
295}
296
297// GetMotionEventsReply is a zero-copy view over a GetMotionEvents reply; offsets count from reply byte 0.
298// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
299type GetMotionEventsReply struct{ raw []byte }
300
301// ParseGetMotionEventsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
302func ParseGetMotionEventsReply(raw []byte) (GetMotionEventsReply, bool) {
303 if len(raw) < 32 {
304 return GetMotionEventsReply{}, false
305 }
306 r := GetMotionEventsReply{raw: raw}
307 off := 32
308 {
309 n := int(r.EventsLen())
310 if n < 0 || n > len(r.raw) {
311 return GetMotionEventsReply{}, false
312 }
313 off += n * 8
314 }
315 if off > len(r.raw) {
316 return GetMotionEventsReply{}, false
317 }
318 if off > len(r.raw) {
319 return GetMotionEventsReply{}, false
320 }
321 return r, true
322}
323func (r GetMotionEventsReply) Raw() []byte { return r.raw }
324func (r GetMotionEventsReply) EventsLen() uint32 {
325 return uint32(binary.LittleEndian.Uint32(r.raw[8:]))
326}
327func (r GetMotionEventsReply) Events() TimecoordList {
328 off := 32
329 end := off + (int(r.EventsLen()))*8
330 return TimecoordList{b: r.raw[off:end:end]}
331}
332
333// TranslateCoordinatesReply is a zero-copy view over a TranslateCoordinates reply; offsets count from reply byte 0.
334// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
335type TranslateCoordinatesReply struct{ raw []byte }
336
337// ParseTranslateCoordinatesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
338func ParseTranslateCoordinatesReply(raw []byte) (TranslateCoordinatesReply, bool) {
339 if len(raw) < 32 {
340 return TranslateCoordinatesReply{}, false
341 }
342 r := TranslateCoordinatesReply{raw: raw}
343 return r, true
344}
345func (r TranslateCoordinatesReply) Raw() []byte { return r.raw }
346func (r TranslateCoordinatesReply) SameScreen() bool { return (r.raw[1:][0] != 0) }
347func (r TranslateCoordinatesReply) Child() Window {
348 return Window(binary.LittleEndian.Uint32(r.raw[8:]))
349}
350func (r TranslateCoordinatesReply) DstX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) }
351func (r TranslateCoordinatesReply) DstY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) }
352
353// GetInputFocusReply is a zero-copy view over a GetInputFocus reply; offsets count from reply byte 0.
354// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
355type GetInputFocusReply struct{ raw []byte }
356
357// ParseGetInputFocusReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
358func ParseGetInputFocusReply(raw []byte) (GetInputFocusReply, bool) {
359 if len(raw) < 32 {
360 return GetInputFocusReply{}, false
361 }
362 r := GetInputFocusReply{raw: raw}
363 return r, true
364}
365func (r GetInputFocusReply) Raw() []byte { return r.raw }
366func (r GetInputFocusReply) RevertTo() InputFocus { return InputFocus(r.raw[1:][0]) }
367func (r GetInputFocusReply) Focus() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) }
368
369// QueryKeymapReply is a zero-copy view over a QueryKeymap reply; offsets count from reply byte 0.
370// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
371type QueryKeymapReply struct{ raw []byte }
372
373// ParseQueryKeymapReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
374func ParseQueryKeymapReply(raw []byte) (QueryKeymapReply, bool) {
375 if len(raw) < 40 {
376 return QueryKeymapReply{}, false
377 }
378 r := QueryKeymapReply{raw: raw}
379 return r, true
380}
381func (r QueryKeymapReply) Raw() []byte { return r.raw }
382func (r QueryKeymapReply) Keys() []byte { off := 8; end := off + 32; return r.raw[off:end:end] }
383
384// QueryFontReply is a zero-copy view over a QueryFont reply; offsets count from reply byte 0.
385// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
386type QueryFontReply struct{ raw []byte }
387
388// ParseQueryFontReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
389func ParseQueryFontReply(raw []byte) (QueryFontReply, bool) {
390 if len(raw) < 60 {
391 return QueryFontReply{}, false
392 }
393 r := QueryFontReply{raw: raw}
394 off := 60
395 {
396 n := int(r.PropertiesLen())
397 if n < 0 || n > len(r.raw) {
398 return QueryFontReply{}, false
399 }
400 off += n * 8
401 }
402 if off > len(r.raw) {
403 return QueryFontReply{}, false
404 }
405 {
406 n := int(r.CharInfosLen())
407 if n < 0 || n > len(r.raw) {
408 return QueryFontReply{}, false
409 }
410 off += n * 12
411 }
412 if off > len(r.raw) {
413 return QueryFontReply{}, false
414 }
415 if off > len(r.raw) {
416 return QueryFontReply{}, false
417 }
418 return r, true
419}
420func (r QueryFontReply) Raw() []byte { return r.raw }
421func (r QueryFontReply) MinBounds() Charinfo { return GetCharinfo(r.raw[8:]) }
422func (r QueryFontReply) MaxBounds() Charinfo { return GetCharinfo(r.raw[24:]) }
423func (r QueryFontReply) MinCharOrByte2() uint16 {
424 return uint16(binary.LittleEndian.Uint16(r.raw[40:]))
425}
426func (r QueryFontReply) MaxCharOrByte2() uint16 {
427 return uint16(binary.LittleEndian.Uint16(r.raw[42:]))
428}
429func (r QueryFontReply) DefaultChar() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[44:])) }
430func (r QueryFontReply) PropertiesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[46:])) }
431func (r QueryFontReply) DrawDirection() FontDraw { return FontDraw(r.raw[48:][0]) }
432func (r QueryFontReply) MinByte1() uint8 { return uint8(r.raw[49:][0]) }
433func (r QueryFontReply) MaxByte1() uint8 { return uint8(r.raw[50:][0]) }
434func (r QueryFontReply) AllCharsExist() bool { return (r.raw[51:][0] != 0) }
435func (r QueryFontReply) FontAscent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[52:])) }
436func (r QueryFontReply) FontDescent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[54:])) }
437func (r QueryFontReply) CharInfosLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[56:])) }
438func (r QueryFontReply) Properties() FontpropList {
439 off := 60
440 end := off + (int(r.PropertiesLen()))*8
441 return FontpropList{b: r.raw[off:end:end]}
442}
443func (r QueryFontReply) CharInfos() CharinfoList {
444 off := 60
445 {
446 n := int(r.PropertiesLen())
447 off += n * 8
448 }
449 end := off + (int(r.CharInfosLen()))*12
450 return CharinfoList{b: r.raw[off:end:end]}
451}
452
453// QueryTextExtentsReply is a zero-copy view over a QueryTextExtents reply; offsets count from reply byte 0.
454// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
455type QueryTextExtentsReply struct{ raw []byte }
456
457// ParseQueryTextExtentsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
458func ParseQueryTextExtentsReply(raw []byte) (QueryTextExtentsReply, bool) {
459 if len(raw) < 32 {
460 return QueryTextExtentsReply{}, false
461 }
462 r := QueryTextExtentsReply{raw: raw}
463 return r, true
464}
465func (r QueryTextExtentsReply) Raw() []byte { return r.raw }
466func (r QueryTextExtentsReply) DrawDirection() FontDraw { return FontDraw(r.raw[1:][0]) }
467func (r QueryTextExtentsReply) FontAscent() int16 {
468 return int16(binary.LittleEndian.Uint16(r.raw[8:]))
469}
470func (r QueryTextExtentsReply) FontDescent() int16 {
471 return int16(binary.LittleEndian.Uint16(r.raw[10:]))
472}
473func (r QueryTextExtentsReply) OverallAscent() int16 {
474 return int16(binary.LittleEndian.Uint16(r.raw[12:]))
475}
476func (r QueryTextExtentsReply) OverallDescent() int16 {
477 return int16(binary.LittleEndian.Uint16(r.raw[14:]))
478}
479func (r QueryTextExtentsReply) OverallWidth() int32 {
480 return int32(binary.LittleEndian.Uint32(r.raw[16:]))
481}
482func (r QueryTextExtentsReply) OverallLeft() int32 {
483 return int32(binary.LittleEndian.Uint32(r.raw[20:]))
484}
485func (r QueryTextExtentsReply) OverallRight() int32 {
486 return int32(binary.LittleEndian.Uint32(r.raw[24:]))
487}
488
489// ListFontsReply is a zero-copy view over a ListFonts reply; offsets count from reply byte 0.
490// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
491type ListFontsReply struct{ raw []byte }
492
493// ParseListFontsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
494func ParseListFontsReply(raw []byte) (ListFontsReply, bool) {
495 if len(raw) < 32 {
496 return ListFontsReply{}, false
497 }
498 r := ListFontsReply{raw: raw}
499 off := 32
500 {
501 n := int(r.NamesLen())
502 if off > len(r.raw) || n < 0 || n > len(r.raw) {
503 return ListFontsReply{}, false
504 }
505 it := NewStrIter(r.raw[off:], n)
506 for it.Next() {
507 off += it.Value().Size()
508 }
509 if it.Err() {
510 return ListFontsReply{}, false
511 }
512 }
513 if off > len(r.raw) {
514 return ListFontsReply{}, false
515 }
516 return r, true
517}
518func (r ListFontsReply) Raw() []byte { return r.raw }
519func (r ListFontsReply) NamesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
520func (r ListFontsReply) Names() StrIter { off := 32; return NewStrIter(r.raw[off:], int(r.NamesLen())) }
521
522// ListFontsWithInfoReply is a zero-copy view over a ListFontsWithInfo reply; offsets count from reply byte 0.
523// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
524type ListFontsWithInfoReply struct{ raw []byte }
525
526// ParseListFontsWithInfoReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
527func ParseListFontsWithInfoReply(raw []byte) (ListFontsWithInfoReply, bool) {
528 if len(raw) < 60 {
529 return ListFontsWithInfoReply{}, false
530 }
531 r := ListFontsWithInfoReply{raw: raw}
532 off := 60
533 {
534 n := int(r.PropertiesLen())
535 if n < 0 || n > len(r.raw) {
536 return ListFontsWithInfoReply{}, false
537 }
538 off += n * 8
539 }
540 if off > len(r.raw) {
541 return ListFontsWithInfoReply{}, false
542 }
543 {
544 n := int(r.NameLen())
545 if n < 0 || n > len(r.raw) {
546 return ListFontsWithInfoReply{}, false
547 }
548 off += n * 1
549 }
550 if off > len(r.raw) {
551 return ListFontsWithInfoReply{}, false
552 }
553 if off > len(r.raw) {
554 return ListFontsWithInfoReply{}, false
555 }
556 return r, true
557}
558func (r ListFontsWithInfoReply) Raw() []byte { return r.raw }
559func (r ListFontsWithInfoReply) NameLen() uint8 { return uint8(r.raw[1:][0]) }
560func (r ListFontsWithInfoReply) MinBounds() Charinfo { return GetCharinfo(r.raw[8:]) }
561func (r ListFontsWithInfoReply) MaxBounds() Charinfo { return GetCharinfo(r.raw[24:]) }
562func (r ListFontsWithInfoReply) MinCharOrByte2() uint16 {
563 return uint16(binary.LittleEndian.Uint16(r.raw[40:]))
564}
565func (r ListFontsWithInfoReply) MaxCharOrByte2() uint16 {
566 return uint16(binary.LittleEndian.Uint16(r.raw[42:]))
567}
568func (r ListFontsWithInfoReply) DefaultChar() uint16 {
569 return uint16(binary.LittleEndian.Uint16(r.raw[44:]))
570}
571func (r ListFontsWithInfoReply) PropertiesLen() uint16 {
572 return uint16(binary.LittleEndian.Uint16(r.raw[46:]))
573}
574func (r ListFontsWithInfoReply) DrawDirection() FontDraw { return FontDraw(r.raw[48:][0]) }
575func (r ListFontsWithInfoReply) MinByte1() uint8 { return uint8(r.raw[49:][0]) }
576func (r ListFontsWithInfoReply) MaxByte1() uint8 { return uint8(r.raw[50:][0]) }
577func (r ListFontsWithInfoReply) AllCharsExist() bool { return (r.raw[51:][0] != 0) }
578func (r ListFontsWithInfoReply) FontAscent() int16 {
579 return int16(binary.LittleEndian.Uint16(r.raw[52:]))
580}
581func (r ListFontsWithInfoReply) FontDescent() int16 {
582 return int16(binary.LittleEndian.Uint16(r.raw[54:]))
583}
584func (r ListFontsWithInfoReply) RepliesHint() uint32 {
585 return uint32(binary.LittleEndian.Uint32(r.raw[56:]))
586}
587func (r ListFontsWithInfoReply) Properties() FontpropList {
588 off := 60
589 end := off + (int(r.PropertiesLen()))*8
590 return FontpropList{b: r.raw[off:end:end]}
591}
592func (r ListFontsWithInfoReply) Name() []byte {
593 off := 60
594 {
595 n := int(r.PropertiesLen())
596 off += n * 8
597 }
598 end := off + int(r.NameLen())
599 return r.raw[off:end:end]
600}
601
602// GetFontPathReply is a zero-copy view over a GetFontPath reply; offsets count from reply byte 0.
603// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
604type GetFontPathReply struct{ raw []byte }
605
606// ParseGetFontPathReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
607func ParseGetFontPathReply(raw []byte) (GetFontPathReply, bool) {
608 if len(raw) < 32 {
609 return GetFontPathReply{}, false
610 }
611 r := GetFontPathReply{raw: raw}
612 off := 32
613 {
614 n := int(r.PathLen())
615 if off > len(r.raw) || n < 0 || n > len(r.raw) {
616 return GetFontPathReply{}, false
617 }
618 it := NewStrIter(r.raw[off:], n)
619 for it.Next() {
620 off += it.Value().Size()
621 }
622 if it.Err() {
623 return GetFontPathReply{}, false
624 }
625 }
626 if off > len(r.raw) {
627 return GetFontPathReply{}, false
628 }
629 return r, true
630}
631func (r GetFontPathReply) Raw() []byte { return r.raw }
632func (r GetFontPathReply) PathLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
633func (r GetFontPathReply) Path() StrIter { off := 32; return NewStrIter(r.raw[off:], int(r.PathLen())) }
634
635// GetImageReply is a zero-copy view over a GetImage reply; offsets count from reply byte 0.
636// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
637type GetImageReply struct{ raw []byte }
638
639// ParseGetImageReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
640func ParseGetImageReply(raw []byte) (GetImageReply, bool) {
641 if len(raw) < 32 {
642 return GetImageReply{}, false
643 }
644 r := GetImageReply{raw: raw}
645 off := 32
646 {
647 n := (int(binary.LittleEndian.Uint32(r.raw[4:])) * 4)
648 if n < 0 || n > len(r.raw) {
649 return GetImageReply{}, false
650 }
651 off += n * 1
652 }
653 if off > len(r.raw) {
654 return GetImageReply{}, false
655 }
656 if off > len(r.raw) {
657 return GetImageReply{}, false
658 }
659 return r, true
660}
661func (r GetImageReply) Raw() []byte { return r.raw }
662func (r GetImageReply) Depth() uint8 { return uint8(r.raw[1:][0]) }
663func (r GetImageReply) Visual() Visualid { return Visualid(binary.LittleEndian.Uint32(r.raw[8:])) }
664func (r GetImageReply) Data() []byte {
665 off := 32
666 end := off + (int(binary.LittleEndian.Uint32(r.raw[4:])) * 4)
667 return r.raw[off:end:end]
668}
669
670// ListInstalledColormapsReply is a zero-copy view over a ListInstalledColormaps reply; offsets count from reply byte 0.
671// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
672type ListInstalledColormapsReply struct{ raw []byte }
673
674// ParseListInstalledColormapsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
675func ParseListInstalledColormapsReply(raw []byte) (ListInstalledColormapsReply, bool) {
676 if len(raw) < 32 {
677 return ListInstalledColormapsReply{}, false
678 }
679 r := ListInstalledColormapsReply{raw: raw}
680 off := 32
681 {
682 n := int(r.CmapsLen())
683 if n < 0 || n > len(r.raw) {
684 return ListInstalledColormapsReply{}, false
685 }
686 off += n * 4
687 }
688 if off > len(r.raw) {
689 return ListInstalledColormapsReply{}, false
690 }
691 if off > len(r.raw) {
692 return ListInstalledColormapsReply{}, false
693 }
694 return r, true
695}
696func (r ListInstalledColormapsReply) Raw() []byte { return r.raw }
697func (r ListInstalledColormapsReply) CmapsLen() uint16 {
698 return uint16(binary.LittleEndian.Uint16(r.raw[8:]))
699}
700func (r ListInstalledColormapsReply) Cmaps() ColormapList {
701 off := 32
702 end := off + (int(r.CmapsLen()))*4
703 return ColormapList{b: r.raw[off:end:end]}
704}
705
706// AllocColorReply is a zero-copy view over a AllocColor reply; offsets count from reply byte 0.
707// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
708type AllocColorReply struct{ raw []byte }
709
710// ParseAllocColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
711func ParseAllocColorReply(raw []byte) (AllocColorReply, bool) {
712 if len(raw) < 32 {
713 return AllocColorReply{}, false
714 }
715 r := AllocColorReply{raw: raw}
716 return r, true
717}
718func (r AllocColorReply) Raw() []byte { return r.raw }
719func (r AllocColorReply) Red() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
720func (r AllocColorReply) Green() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) }
721func (r AllocColorReply) Blue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) }
722func (r AllocColorReply) Pixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) }
723
724// AllocNamedColorReply is a zero-copy view over a AllocNamedColor reply; offsets count from reply byte 0.
725// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
726type AllocNamedColorReply struct{ raw []byte }
727
728// ParseAllocNamedColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
729func ParseAllocNamedColorReply(raw []byte) (AllocNamedColorReply, bool) {
730 if len(raw) < 32 {
731 return AllocNamedColorReply{}, false
732 }
733 r := AllocNamedColorReply{raw: raw}
734 return r, true
735}
736func (r AllocNamedColorReply) Raw() []byte { return r.raw }
737func (r AllocNamedColorReply) Pixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) }
738func (r AllocNamedColorReply) ExactRed() uint16 {
739 return uint16(binary.LittleEndian.Uint16(r.raw[12:]))
740}
741func (r AllocNamedColorReply) ExactGreen() uint16 {
742 return uint16(binary.LittleEndian.Uint16(r.raw[14:]))
743}
744func (r AllocNamedColorReply) ExactBlue() uint16 {
745 return uint16(binary.LittleEndian.Uint16(r.raw[16:]))
746}
747func (r AllocNamedColorReply) VisualRed() uint16 {
748 return uint16(binary.LittleEndian.Uint16(r.raw[18:]))
749}
750func (r AllocNamedColorReply) VisualGreen() uint16 {
751 return uint16(binary.LittleEndian.Uint16(r.raw[20:]))
752}
753func (r AllocNamedColorReply) VisualBlue() uint16 {
754 return uint16(binary.LittleEndian.Uint16(r.raw[22:]))
755}
756
757// AllocColorCellsReply is a zero-copy view over a AllocColorCells reply; offsets count from reply byte 0.
758// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
759type AllocColorCellsReply struct{ raw []byte }
760
761// ParseAllocColorCellsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
762func ParseAllocColorCellsReply(raw []byte) (AllocColorCellsReply, bool) {
763 if len(raw) < 32 {
764 return AllocColorCellsReply{}, false
765 }
766 r := AllocColorCellsReply{raw: raw}
767 off := 32
768 {
769 n := int(r.PixelsLen())
770 if n < 0 || n > len(r.raw) {
771 return AllocColorCellsReply{}, false
772 }
773 off += n * 4
774 }
775 if off > len(r.raw) {
776 return AllocColorCellsReply{}, false
777 }
778 {
779 n := int(r.MasksLen())
780 if n < 0 || n > len(r.raw) {
781 return AllocColorCellsReply{}, false
782 }
783 off += n * 4
784 }
785 if off > len(r.raw) {
786 return AllocColorCellsReply{}, false
787 }
788 if off > len(r.raw) {
789 return AllocColorCellsReply{}, false
790 }
791 return r, true
792}
793func (r AllocColorCellsReply) Raw() []byte { return r.raw }
794func (r AllocColorCellsReply) PixelsLen() uint16 {
795 return uint16(binary.LittleEndian.Uint16(r.raw[8:]))
796}
797func (r AllocColorCellsReply) MasksLen() uint16 {
798 return uint16(binary.LittleEndian.Uint16(r.raw[10:]))
799}
800func (r AllocColorCellsReply) Pixels() Uint32List {
801 off := 32
802 end := off + (int(r.PixelsLen()))*4
803 return Uint32List{b: r.raw[off:end:end]}
804}
805func (r AllocColorCellsReply) Masks() Uint32List {
806 off := 32
807 {
808 n := int(r.PixelsLen())
809 off += n * 4
810 }
811 end := off + (int(r.MasksLen()))*4
812 return Uint32List{b: r.raw[off:end:end]}
813}
814
815// AllocColorPlanesReply is a zero-copy view over a AllocColorPlanes reply; offsets count from reply byte 0.
816// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
817type AllocColorPlanesReply struct{ raw []byte }
818
819// ParseAllocColorPlanesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
820func ParseAllocColorPlanesReply(raw []byte) (AllocColorPlanesReply, bool) {
821 if len(raw) < 32 {
822 return AllocColorPlanesReply{}, false
823 }
824 r := AllocColorPlanesReply{raw: raw}
825 off := 32
826 {
827 n := int(r.PixelsLen())
828 if n < 0 || n > len(r.raw) {
829 return AllocColorPlanesReply{}, false
830 }
831 off += n * 4
832 }
833 if off > len(r.raw) {
834 return AllocColorPlanesReply{}, false
835 }
836 if off > len(r.raw) {
837 return AllocColorPlanesReply{}, false
838 }
839 return r, true
840}
841func (r AllocColorPlanesReply) Raw() []byte { return r.raw }
842func (r AllocColorPlanesReply) PixelsLen() uint16 {
843 return uint16(binary.LittleEndian.Uint16(r.raw[8:]))
844}
845func (r AllocColorPlanesReply) RedMask() uint32 {
846 return uint32(binary.LittleEndian.Uint32(r.raw[12:]))
847}
848func (r AllocColorPlanesReply) GreenMask() uint32 {
849 return uint32(binary.LittleEndian.Uint32(r.raw[16:]))
850}
851func (r AllocColorPlanesReply) BlueMask() uint32 {
852 return uint32(binary.LittleEndian.Uint32(r.raw[20:]))
853}
854func (r AllocColorPlanesReply) Pixels() Uint32List {
855 off := 32
856 end := off + (int(r.PixelsLen()))*4
857 return Uint32List{b: r.raw[off:end:end]}
858}
859
860// QueryColorsReply is a zero-copy view over a QueryColors reply; offsets count from reply byte 0.
861// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
862type QueryColorsReply struct{ raw []byte }
863
864// ParseQueryColorsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
865func ParseQueryColorsReply(raw []byte) (QueryColorsReply, bool) {
866 if len(raw) < 32 {
867 return QueryColorsReply{}, false
868 }
869 r := QueryColorsReply{raw: raw}
870 off := 32
871 {
872 n := int(r.ColorsLen())
873 if n < 0 || n > len(r.raw) {
874 return QueryColorsReply{}, false
875 }
876 off += n * 8
877 }
878 if off > len(r.raw) {
879 return QueryColorsReply{}, false
880 }
881 if off > len(r.raw) {
882 return QueryColorsReply{}, false
883 }
884 return r, true
885}
886func (r QueryColorsReply) Raw() []byte { return r.raw }
887func (r QueryColorsReply) ColorsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
888func (r QueryColorsReply) Colors() RgbList {
889 off := 32
890 end := off + (int(r.ColorsLen()))*8
891 return RgbList{b: r.raw[off:end:end]}
892}
893
894// LookupColorReply is a zero-copy view over a LookupColor reply; offsets count from reply byte 0.
895// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
896type LookupColorReply struct{ raw []byte }
897
898// ParseLookupColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
899func ParseLookupColorReply(raw []byte) (LookupColorReply, bool) {
900 if len(raw) < 32 {
901 return LookupColorReply{}, false
902 }
903 r := LookupColorReply{raw: raw}
904 return r, true
905}
906func (r LookupColorReply) Raw() []byte { return r.raw }
907func (r LookupColorReply) ExactRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
908func (r LookupColorReply) ExactGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) }
909func (r LookupColorReply) ExactBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) }
910func (r LookupColorReply) VisualRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[14:])) }
911func (r LookupColorReply) VisualGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) }
912func (r LookupColorReply) VisualBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) }
913
914// QueryBestSizeReply is a zero-copy view over a QueryBestSize reply; offsets count from reply byte 0.
915// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
916type QueryBestSizeReply struct{ raw []byte }
917
918// ParseQueryBestSizeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
919func ParseQueryBestSizeReply(raw []byte) (QueryBestSizeReply, bool) {
920 if len(raw) < 32 {
921 return QueryBestSizeReply{}, false
922 }
923 r := QueryBestSizeReply{raw: raw}
924 return r, true
925}
926func (r QueryBestSizeReply) Raw() []byte { return r.raw }
927func (r QueryBestSizeReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
928func (r QueryBestSizeReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) }
929
930// QueryExtensionReply is a zero-copy view over a QueryExtension reply; offsets count from reply byte 0.
931// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
932type QueryExtensionReply struct{ raw []byte }
933
934// ParseQueryExtensionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
935func ParseQueryExtensionReply(raw []byte) (QueryExtensionReply, bool) {
936 if len(raw) < 32 {
937 return QueryExtensionReply{}, false
938 }
939 r := QueryExtensionReply{raw: raw}
940 return r, true
941}
942func (r QueryExtensionReply) Raw() []byte { return r.raw }
943func (r QueryExtensionReply) Present() bool { return (r.raw[8:][0] != 0) }
944func (r QueryExtensionReply) MajorOpcode() uint8 { return uint8(r.raw[9:][0]) }
945func (r QueryExtensionReply) FirstEvent() uint8 { return uint8(r.raw[10:][0]) }
946func (r QueryExtensionReply) FirstError() uint8 { return uint8(r.raw[11:][0]) }
947
948// ListExtensionsReply is a zero-copy view over a ListExtensions reply; offsets count from reply byte 0.
949// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
950type ListExtensionsReply struct{ raw []byte }
951
952// ParseListExtensionsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
953func ParseListExtensionsReply(raw []byte) (ListExtensionsReply, bool) {
954 if len(raw) < 32 {
955 return ListExtensionsReply{}, false
956 }
957 r := ListExtensionsReply{raw: raw}
958 off := 32
959 {
960 n := int(r.NamesLen())
961 if off > len(r.raw) || n < 0 || n > len(r.raw) {
962 return ListExtensionsReply{}, false
963 }
964 it := NewStrIter(r.raw[off:], n)
965 for it.Next() {
966 off += it.Value().Size()
967 }
968 if it.Err() {
969 return ListExtensionsReply{}, false
970 }
971 }
972 if off > len(r.raw) {
973 return ListExtensionsReply{}, false
974 }
975 return r, true
976}
977func (r ListExtensionsReply) Raw() []byte { return r.raw }
978func (r ListExtensionsReply) NamesLen() uint8 { return uint8(r.raw[1:][0]) }
979func (r ListExtensionsReply) Names() StrIter {
980 off := 32
981 return NewStrIter(r.raw[off:], int(r.NamesLen()))
982}
983
984// GetKeyboardMappingReply is a zero-copy view over a GetKeyboardMapping reply; offsets count from reply byte 0.
985// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
986type GetKeyboardMappingReply struct{ raw []byte }
987
988// ParseGetKeyboardMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
989func ParseGetKeyboardMappingReply(raw []byte) (GetKeyboardMappingReply, bool) {
990 if len(raw) < 32 {
991 return GetKeyboardMappingReply{}, false
992 }
993 r := GetKeyboardMappingReply{raw: raw}
994 off := 32
995 {
996 n := int(binary.LittleEndian.Uint32(r.raw[4:]))
997 if n < 0 || n > len(r.raw) {
998 return GetKeyboardMappingReply{}, false
999 }
1000 off += n * 4
1001 }
1002 if off > len(r.raw) {
1003 return GetKeyboardMappingReply{}, false
1004 }
1005 if off > len(r.raw) {
1006 return GetKeyboardMappingReply{}, false
1007 }
1008 return r, true
1009}
1010func (r GetKeyboardMappingReply) Raw() []byte { return r.raw }
1011func (r GetKeyboardMappingReply) KeysymsPerKeycode() byte { return byte(r.raw[1:][0]) }
1012func (r GetKeyboardMappingReply) Keysyms() KeysymList {
1013 off := 32
1014 end := off + (int(binary.LittleEndian.Uint32(r.raw[4:])))*4
1015 return KeysymList{b: r.raw[off:end:end]}
1016}
1017
1018// GetKeyboardControlReply is a zero-copy view over a GetKeyboardControl reply; offsets count from reply byte 0.
1019// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1020type GetKeyboardControlReply struct{ raw []byte }
1021
1022// ParseGetKeyboardControlReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1023func ParseGetKeyboardControlReply(raw []byte) (GetKeyboardControlReply, bool) {
1024 if len(raw) < 52 {
1025 return GetKeyboardControlReply{}, false
1026 }
1027 r := GetKeyboardControlReply{raw: raw}
1028 return r, true
1029}
1030func (r GetKeyboardControlReply) Raw() []byte { return r.raw }
1031func (r GetKeyboardControlReply) GlobalAutoRepeat() AutoRepeatMode {
1032 return AutoRepeatMode(r.raw[1:][0])
1033}
1034func (r GetKeyboardControlReply) LedMask() uint32 {
1035 return uint32(binary.LittleEndian.Uint32(r.raw[8:]))
1036}
1037func (r GetKeyboardControlReply) KeyClickPercent() uint8 { return uint8(r.raw[12:][0]) }
1038func (r GetKeyboardControlReply) BellPercent() uint8 { return uint8(r.raw[13:][0]) }
1039func (r GetKeyboardControlReply) BellPitch() uint16 {
1040 return uint16(binary.LittleEndian.Uint16(r.raw[14:]))
1041}
1042func (r GetKeyboardControlReply) BellDuration() uint16 {
1043 return uint16(binary.LittleEndian.Uint16(r.raw[16:]))
1044}
1045func (r GetKeyboardControlReply) AutoRepeats() []byte {
1046 off := 20
1047 end := off + 32
1048 return r.raw[off:end:end]
1049}
1050
1051// GetPointerControlReply is a zero-copy view over a GetPointerControl reply; offsets count from reply byte 0.
1052// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1053type GetPointerControlReply struct{ raw []byte }
1054
1055// ParseGetPointerControlReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1056func ParseGetPointerControlReply(raw []byte) (GetPointerControlReply, bool) {
1057 if len(raw) < 32 {
1058 return GetPointerControlReply{}, false
1059 }
1060 r := GetPointerControlReply{raw: raw}
1061 return r, true
1062}
1063func (r GetPointerControlReply) Raw() []byte { return r.raw }
1064func (r GetPointerControlReply) AccelerationNumerator() uint16 {
1065 return uint16(binary.LittleEndian.Uint16(r.raw[8:]))
1066}
1067func (r GetPointerControlReply) AccelerationDenominator() uint16 {
1068 return uint16(binary.LittleEndian.Uint16(r.raw[10:]))
1069}
1070func (r GetPointerControlReply) Threshold() uint16 {
1071 return uint16(binary.LittleEndian.Uint16(r.raw[12:]))
1072}
1073
1074// GetScreenSaverReply is a zero-copy view over a GetScreenSaver reply; offsets count from reply byte 0.
1075// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1076type GetScreenSaverReply struct{ raw []byte }
1077
1078// ParseGetScreenSaverReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1079func ParseGetScreenSaverReply(raw []byte) (GetScreenSaverReply, bool) {
1080 if len(raw) < 32 {
1081 return GetScreenSaverReply{}, false
1082 }
1083 r := GetScreenSaverReply{raw: raw}
1084 return r, true
1085}
1086func (r GetScreenSaverReply) Raw() []byte { return r.raw }
1087func (r GetScreenSaverReply) Timeout() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
1088func (r GetScreenSaverReply) Interval() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) }
1089func (r GetScreenSaverReply) PreferBlanking() Blanking { return Blanking(r.raw[12:][0]) }
1090func (r GetScreenSaverReply) AllowExposures() Exposures { return Exposures(r.raw[13:][0]) }
1091
1092// ListHostsReply is a zero-copy view over a ListHosts reply; offsets count from reply byte 0.
1093// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1094type ListHostsReply struct{ raw []byte }
1095
1096// ParseListHostsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1097func ParseListHostsReply(raw []byte) (ListHostsReply, bool) {
1098 if len(raw) < 32 {
1099 return ListHostsReply{}, false
1100 }
1101 r := ListHostsReply{raw: raw}
1102 off := 32
1103 {
1104 n := int(r.HostsLen())
1105 if off > len(r.raw) || n < 0 || n > len(r.raw) {
1106 return ListHostsReply{}, false
1107 }
1108 it := NewHostIter(r.raw[off:], n)
1109 for it.Next() {
1110 off += it.Value().Size()
1111 }
1112 if it.Err() {
1113 return ListHostsReply{}, false
1114 }
1115 }
1116 if off > len(r.raw) {
1117 return ListHostsReply{}, false
1118 }
1119 return r, true
1120}
1121func (r ListHostsReply) Raw() []byte { return r.raw }
1122func (r ListHostsReply) Mode() AccessControl { return AccessControl(r.raw[1:][0]) }
1123func (r ListHostsReply) HostsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) }
1124func (r ListHostsReply) Hosts() HostIter {
1125 off := 32
1126 return NewHostIter(r.raw[off:], int(r.HostsLen()))
1127}
1128
1129// SetPointerMappingReply is a zero-copy view over a SetPointerMapping reply; offsets count from reply byte 0.
1130// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1131type SetPointerMappingReply struct{ raw []byte }
1132
1133// ParseSetPointerMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1134func ParseSetPointerMappingReply(raw []byte) (SetPointerMappingReply, bool) {
1135 if len(raw) < 32 {
1136 return SetPointerMappingReply{}, false
1137 }
1138 r := SetPointerMappingReply{raw: raw}
1139 return r, true
1140}
1141func (r SetPointerMappingReply) Raw() []byte { return r.raw }
1142func (r SetPointerMappingReply) Status() MappingStatus { return MappingStatus(r.raw[1:][0]) }
1143
1144// GetPointerMappingReply is a zero-copy view over a GetPointerMapping reply; offsets count from reply byte 0.
1145// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1146type GetPointerMappingReply struct{ raw []byte }
1147
1148// ParseGetPointerMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1149func ParseGetPointerMappingReply(raw []byte) (GetPointerMappingReply, bool) {
1150 if len(raw) < 32 {
1151 return GetPointerMappingReply{}, false
1152 }
1153 r := GetPointerMappingReply{raw: raw}
1154 off := 32
1155 {
1156 n := int(r.MapLen())
1157 if n < 0 || n > len(r.raw) {
1158 return GetPointerMappingReply{}, false
1159 }
1160 off += n * 1
1161 }
1162 if off > len(r.raw) {
1163 return GetPointerMappingReply{}, false
1164 }
1165 if off > len(r.raw) {
1166 return GetPointerMappingReply{}, false
1167 }
1168 return r, true
1169}
1170func (r GetPointerMappingReply) Raw() []byte { return r.raw }
1171func (r GetPointerMappingReply) MapLen() uint8 { return uint8(r.raw[1:][0]) }
1172func (r GetPointerMappingReply) Map() []byte {
1173 off := 32
1174 end := off + int(r.MapLen())
1175 return r.raw[off:end:end]
1176}
1177
1178// SetModifierMappingReply is a zero-copy view over a SetModifierMapping reply; offsets count from reply byte 0.
1179// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1180type SetModifierMappingReply struct{ raw []byte }
1181
1182// ParseSetModifierMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1183func ParseSetModifierMappingReply(raw []byte) (SetModifierMappingReply, bool) {
1184 if len(raw) < 32 {
1185 return SetModifierMappingReply{}, false
1186 }
1187 r := SetModifierMappingReply{raw: raw}
1188 return r, true
1189}
1190func (r SetModifierMappingReply) Raw() []byte { return r.raw }
1191func (r SetModifierMappingReply) Status() MappingStatus { return MappingStatus(r.raw[1:][0]) }
1192
1193// GetModifierMappingReply is a zero-copy view over a GetModifierMapping reply; offsets count from reply byte 0.
1194// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
1195type GetModifierMappingReply struct{ raw []byte }
1196
1197// ParseGetModifierMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
1198func ParseGetModifierMappingReply(raw []byte) (GetModifierMappingReply, bool) {
1199 if len(raw) < 32 {
1200 return GetModifierMappingReply{}, false
1201 }
1202 r := GetModifierMappingReply{raw: raw}
1203 off := 32
1204 {
1205 n := (int(r.KeycodesPerModifier()) * 8)
1206 if n < 0 || n > len(r.raw) {
1207 return GetModifierMappingReply{}, false
1208 }
1209 off += n * 1
1210 }
1211 if off > len(r.raw) {
1212 return GetModifierMappingReply{}, false
1213 }
1214 if off > len(r.raw) {
1215 return GetModifierMappingReply{}, false
1216 }
1217 return r, true
1218}
1219func (r GetModifierMappingReply) Raw() []byte { return r.raw }
1220func (r GetModifierMappingReply) KeycodesPerModifier() uint8 { return uint8(r.raw[1:][0]) }
1221func (r GetModifierMappingReply) Keycodes() KeycodeList {
1222 off := 32
1223 end := off + (int(r.KeycodesPerModifier())*8)*1
1224 return KeycodeList{b: r.raw[off:end:end]}
1225}
1226
1227// DepthView is a zero-copy view over one wire-encoded Depth, yielded by DepthIter.
1228// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1229type DepthView struct{ raw []byte }
1230
1231func (v DepthView) Raw() []byte { return v.raw }
1232
1233// Size is the element's wire size, including trailing alignment.
1234func (v DepthView) Size() int { return len(v.raw) }
1235func sizeDepth(p []byte) int {
1236 if len(p) < 8 {
1237 return -1
1238 }
1239 v := DepthView{raw: p}
1240 _ = v
1241 off := 8
1242 {
1243 n := int(v.VisualsLen())
1244 if n < 0 || n > len(v.raw) {
1245 return -1
1246 }
1247 off += n * 24
1248 }
1249 if off > len(v.raw) {
1250 return -1
1251 }
1252 if off > len(v.raw) {
1253 return -1
1254 }
1255 return off
1256}
1257func (v DepthView) Depth() uint8 { return uint8(v.raw[0:][0]) }
1258func (v DepthView) VisualsLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) }
1259func (v DepthView) Visuals() VisualtypeList {
1260 off := 8
1261 end := off + (int(v.VisualsLen()))*24
1262 return VisualtypeList{b: v.raw[off:end:end]}
1263}
1264
1265// DepthIter walks n consecutive Depth elements; Err reports a malformed length.
1266// It shares the lifetime of the bytes it walks.
1267type DepthIter struct {
1268 b []byte
1269 n int
1270 v DepthView
1271 err bool
1272}
1273
1274// NewDepthIter iterates n elements encoded at the start of b.
1275func NewDepthIter(b []byte, n int) DepthIter { return DepthIter{b: b, n: n} }
1276func (it *DepthIter) Next() bool {
1277 if it.n <= 0 || it.err {
1278 return false
1279 }
1280 s := sizeDepth(it.b)
1281 if s < 0 {
1282 it.err = true
1283 it.n = 0
1284 return false
1285 }
1286 it.v = DepthView{raw: it.b[:s:s]}
1287 it.b = it.b[s:]
1288 it.n--
1289 return true
1290}
1291func (it *DepthIter) Value() DepthView { return it.v }
1292func (it *DepthIter) Err() bool { return it.err }
1293
1294// ScreenView is a zero-copy view over one wire-encoded Screen, yielded by ScreenIter.
1295// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1296type ScreenView struct{ raw []byte }
1297
1298func (v ScreenView) Raw() []byte { return v.raw }
1299
1300// Size is the element's wire size, including trailing alignment.
1301func (v ScreenView) Size() int { return len(v.raw) }
1302func sizeScreen(p []byte) int {
1303 if len(p) < 40 {
1304 return -1
1305 }
1306 v := ScreenView{raw: p}
1307 _ = v
1308 off := 40
1309 {
1310 n := int(v.AllowedDepthsLen())
1311 if off > len(v.raw) || n < 0 || n > len(v.raw) {
1312 return -1
1313 }
1314 it := NewDepthIter(v.raw[off:], n)
1315 for it.Next() {
1316 off += it.Value().Size()
1317 }
1318 if it.Err() {
1319 return -1
1320 }
1321 }
1322 if off > len(v.raw) {
1323 return -1
1324 }
1325 return off
1326}
1327func (v ScreenView) Root() Window { return Window(binary.LittleEndian.Uint32(v.raw[0:])) }
1328func (v ScreenView) DefaultColormap() Colormap {
1329 return Colormap(binary.LittleEndian.Uint32(v.raw[4:]))
1330}
1331func (v ScreenView) WhitePixel() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) }
1332func (v ScreenView) BlackPixel() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[12:])) }
1333func (v ScreenView) CurrentInputMasks() EventMask {
1334 return EventMask(binary.LittleEndian.Uint32(v.raw[16:]))
1335}
1336func (v ScreenView) WidthInPixels() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[20:])) }
1337func (v ScreenView) HeightInPixels() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[22:])) }
1338func (v ScreenView) WidthInMillimeters() uint16 {
1339 return uint16(binary.LittleEndian.Uint16(v.raw[24:]))
1340}
1341func (v ScreenView) HeightInMillimeters() uint16 {
1342 return uint16(binary.LittleEndian.Uint16(v.raw[26:]))
1343}
1344func (v ScreenView) MinInstalledMaps() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[28:])) }
1345func (v ScreenView) MaxInstalledMaps() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[30:])) }
1346func (v ScreenView) RootVisual() Visualid { return Visualid(binary.LittleEndian.Uint32(v.raw[32:])) }
1347func (v ScreenView) BackingStores() BackingStore { return BackingStore(v.raw[36:][0]) }
1348func (v ScreenView) SaveUnders() bool { return (v.raw[37:][0] != 0) }
1349func (v ScreenView) RootDepth() uint8 { return uint8(v.raw[38:][0]) }
1350func (v ScreenView) AllowedDepthsLen() uint8 { return uint8(v.raw[39:][0]) }
1351func (v ScreenView) AllowedDepths() DepthIter {
1352 off := 40
1353 return NewDepthIter(v.raw[off:], int(v.AllowedDepthsLen()))
1354}
1355
1356// ScreenIter walks n consecutive Screen elements; Err reports a malformed length.
1357// It shares the lifetime of the bytes it walks.
1358type ScreenIter struct {
1359 b []byte
1360 n int
1361 v ScreenView
1362 err bool
1363}
1364
1365// NewScreenIter iterates n elements encoded at the start of b.
1366func NewScreenIter(b []byte, n int) ScreenIter { return ScreenIter{b: b, n: n} }
1367func (it *ScreenIter) Next() bool {
1368 if it.n <= 0 || it.err {
1369 return false
1370 }
1371 s := sizeScreen(it.b)
1372 if s < 0 {
1373 it.err = true
1374 it.n = 0
1375 return false
1376 }
1377 it.v = ScreenView{raw: it.b[:s:s]}
1378 it.b = it.b[s:]
1379 it.n--
1380 return true
1381}
1382func (it *ScreenIter) Value() ScreenView { return it.v }
1383func (it *ScreenIter) Err() bool { return it.err }
1384
1385// SetupRequestView is a zero-copy view over one wire-encoded SetupRequest, yielded by SetupRequestIter.
1386// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1387type SetupRequestView struct{ raw []byte }
1388
1389func (v SetupRequestView) Raw() []byte { return v.raw }
1390
1391// Size is the element's wire size, including trailing alignment.
1392func (v SetupRequestView) Size() int { return len(v.raw) }
1393func sizeSetupRequest(p []byte) int {
1394 if len(p) < 12 {
1395 return -1
1396 }
1397 v := SetupRequestView{raw: p}
1398 _ = v
1399 off := 12
1400 {
1401 n := int(v.AuthorizationProtocolNameLen())
1402 if n < 0 || n > len(v.raw) {
1403 return -1
1404 }
1405 off += n * 1
1406 }
1407 if off > len(v.raw) {
1408 return -1
1409 }
1410 off = (off + 3) &^ 3
1411 {
1412 n := int(v.AuthorizationProtocolDataLen())
1413 if n < 0 || n > len(v.raw) {
1414 return -1
1415 }
1416 off += n * 1
1417 }
1418 if off > len(v.raw) {
1419 return -1
1420 }
1421 off = (off + 3) &^ 3
1422 if off > len(v.raw) {
1423 return -1
1424 }
1425 return off
1426}
1427func (v SetupRequestView) ByteOrder() uint8 { return uint8(v.raw[0:][0]) }
1428func (v SetupRequestView) ProtocolMajorVersion() uint16 {
1429 return uint16(binary.LittleEndian.Uint16(v.raw[2:]))
1430}
1431func (v SetupRequestView) ProtocolMinorVersion() uint16 {
1432 return uint16(binary.LittleEndian.Uint16(v.raw[4:]))
1433}
1434func (v SetupRequestView) AuthorizationProtocolNameLen() uint16 {
1435 return uint16(binary.LittleEndian.Uint16(v.raw[6:]))
1436}
1437func (v SetupRequestView) AuthorizationProtocolDataLen() uint16 {
1438 return uint16(binary.LittleEndian.Uint16(v.raw[8:]))
1439}
1440func (v SetupRequestView) AuthorizationProtocolName() []byte {
1441 off := 12
1442 end := off + int(v.AuthorizationProtocolNameLen())
1443 return v.raw[off:end:end]
1444}
1445func (v SetupRequestView) AuthorizationProtocolData() []byte {
1446 off := 12
1447 {
1448 n := int(v.AuthorizationProtocolNameLen())
1449 off += n * 1
1450 }
1451 off = (off + 3) &^ 3
1452 end := off + int(v.AuthorizationProtocolDataLen())
1453 return v.raw[off:end:end]
1454}
1455
1456// SetupRequestIter walks n consecutive SetupRequest elements; Err reports a malformed length.
1457// It shares the lifetime of the bytes it walks.
1458type SetupRequestIter struct {
1459 b []byte
1460 n int
1461 v SetupRequestView
1462 err bool
1463}
1464
1465// NewSetupRequestIter iterates n elements encoded at the start of b.
1466func NewSetupRequestIter(b []byte, n int) SetupRequestIter { return SetupRequestIter{b: b, n: n} }
1467func (it *SetupRequestIter) Next() bool {
1468 if it.n <= 0 || it.err {
1469 return false
1470 }
1471 s := sizeSetupRequest(it.b)
1472 if s < 0 {
1473 it.err = true
1474 it.n = 0
1475 return false
1476 }
1477 it.v = SetupRequestView{raw: it.b[:s:s]}
1478 it.b = it.b[s:]
1479 it.n--
1480 return true
1481}
1482func (it *SetupRequestIter) Value() SetupRequestView { return it.v }
1483func (it *SetupRequestIter) Err() bool { return it.err }
1484
1485// SetupFailedView is a zero-copy view over one wire-encoded SetupFailed, yielded by SetupFailedIter.
1486// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1487type SetupFailedView struct{ raw []byte }
1488
1489func (v SetupFailedView) Raw() []byte { return v.raw }
1490
1491// Size is the element's wire size, including trailing alignment.
1492func (v SetupFailedView) Size() int { return len(v.raw) }
1493func sizeSetupFailed(p []byte) int {
1494 if len(p) < 8 {
1495 return -1
1496 }
1497 v := SetupFailedView{raw: p}
1498 _ = v
1499 off := 8
1500 {
1501 n := int(v.ReasonLen())
1502 if n < 0 || n > len(v.raw) {
1503 return -1
1504 }
1505 off += n * 1
1506 }
1507 if off > len(v.raw) {
1508 return -1
1509 }
1510 if off > len(v.raw) {
1511 return -1
1512 }
1513 return off
1514}
1515func (v SetupFailedView) Status() uint8 { return uint8(v.raw[0:][0]) }
1516func (v SetupFailedView) ReasonLen() uint8 { return uint8(v.raw[1:][0]) }
1517func (v SetupFailedView) ProtocolMajorVersion() uint16 {
1518 return uint16(binary.LittleEndian.Uint16(v.raw[2:]))
1519}
1520func (v SetupFailedView) ProtocolMinorVersion() uint16 {
1521 return uint16(binary.LittleEndian.Uint16(v.raw[4:]))
1522}
1523func (v SetupFailedView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) }
1524func (v SetupFailedView) Reason() []byte {
1525 off := 8
1526 end := off + int(v.ReasonLen())
1527 return v.raw[off:end:end]
1528}
1529
1530// SetupFailedIter walks n consecutive SetupFailed elements; Err reports a malformed length.
1531// It shares the lifetime of the bytes it walks.
1532type SetupFailedIter struct {
1533 b []byte
1534 n int
1535 v SetupFailedView
1536 err bool
1537}
1538
1539// NewSetupFailedIter iterates n elements encoded at the start of b.
1540func NewSetupFailedIter(b []byte, n int) SetupFailedIter { return SetupFailedIter{b: b, n: n} }
1541func (it *SetupFailedIter) Next() bool {
1542 if it.n <= 0 || it.err {
1543 return false
1544 }
1545 s := sizeSetupFailed(it.b)
1546 if s < 0 {
1547 it.err = true
1548 it.n = 0
1549 return false
1550 }
1551 it.v = SetupFailedView{raw: it.b[:s:s]}
1552 it.b = it.b[s:]
1553 it.n--
1554 return true
1555}
1556func (it *SetupFailedIter) Value() SetupFailedView { return it.v }
1557func (it *SetupFailedIter) Err() bool { return it.err }
1558
1559// SetupAuthenticateView is a zero-copy view over one wire-encoded SetupAuthenticate, yielded by SetupAuthenticateIter.
1560// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1561type SetupAuthenticateView struct{ raw []byte }
1562
1563func (v SetupAuthenticateView) Raw() []byte { return v.raw }
1564
1565// Size is the element's wire size, including trailing alignment.
1566func (v SetupAuthenticateView) Size() int { return len(v.raw) }
1567func sizeSetupAuthenticate(p []byte) int {
1568 if len(p) < 8 {
1569 return -1
1570 }
1571 v := SetupAuthenticateView{raw: p}
1572 _ = v
1573 off := 8
1574 {
1575 n := (int(v.Length()) * 4)
1576 if n < 0 || n > len(v.raw) {
1577 return -1
1578 }
1579 off += n * 1
1580 }
1581 if off > len(v.raw) {
1582 return -1
1583 }
1584 if off > len(v.raw) {
1585 return -1
1586 }
1587 return off
1588}
1589func (v SetupAuthenticateView) Status() uint8 { return uint8(v.raw[0:][0]) }
1590func (v SetupAuthenticateView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) }
1591func (v SetupAuthenticateView) Reason() []byte {
1592 off := 8
1593 end := off + (int(v.Length()) * 4)
1594 return v.raw[off:end:end]
1595}
1596
1597// SetupAuthenticateIter walks n consecutive SetupAuthenticate elements; Err reports a malformed length.
1598// It shares the lifetime of the bytes it walks.
1599type SetupAuthenticateIter struct {
1600 b []byte
1601 n int
1602 v SetupAuthenticateView
1603 err bool
1604}
1605
1606// NewSetupAuthenticateIter iterates n elements encoded at the start of b.
1607func NewSetupAuthenticateIter(b []byte, n int) SetupAuthenticateIter {
1608 return SetupAuthenticateIter{b: b, n: n}
1609}
1610func (it *SetupAuthenticateIter) Next() bool {
1611 if it.n <= 0 || it.err {
1612 return false
1613 }
1614 s := sizeSetupAuthenticate(it.b)
1615 if s < 0 {
1616 it.err = true
1617 it.n = 0
1618 return false
1619 }
1620 it.v = SetupAuthenticateView{raw: it.b[:s:s]}
1621 it.b = it.b[s:]
1622 it.n--
1623 return true
1624}
1625func (it *SetupAuthenticateIter) Value() SetupAuthenticateView { return it.v }
1626func (it *SetupAuthenticateIter) Err() bool { return it.err }
1627
1628// SetupView is a zero-copy view over one wire-encoded Setup, yielded by SetupIter.
1629// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1630type SetupView struct{ raw []byte }
1631
1632func (v SetupView) Raw() []byte { return v.raw }
1633
1634// Size is the element's wire size, including trailing alignment.
1635func (v SetupView) Size() int { return len(v.raw) }
1636func sizeSetup(p []byte) int {
1637 if len(p) < 40 {
1638 return -1
1639 }
1640 v := SetupView{raw: p}
1641 _ = v
1642 off := 40
1643 {
1644 n := int(v.VendorLen())
1645 if n < 0 || n > len(v.raw) {
1646 return -1
1647 }
1648 off += n * 1
1649 }
1650 if off > len(v.raw) {
1651 return -1
1652 }
1653 off = (off + 3) &^ 3
1654 {
1655 n := int(v.PixmapFormatsLen())
1656 if n < 0 || n > len(v.raw) {
1657 return -1
1658 }
1659 off += n * 8
1660 }
1661 if off > len(v.raw) {
1662 return -1
1663 }
1664 {
1665 n := int(v.RootsLen())
1666 if off > len(v.raw) || n < 0 || n > len(v.raw) {
1667 return -1
1668 }
1669 it := NewScreenIter(v.raw[off:], n)
1670 for it.Next() {
1671 off += it.Value().Size()
1672 }
1673 if it.Err() {
1674 return -1
1675 }
1676 }
1677 if off > len(v.raw) {
1678 return -1
1679 }
1680 return off
1681}
1682func (v SetupView) Status() uint8 { return uint8(v.raw[0:][0]) }
1683func (v SetupView) ProtocolMajorVersion() uint16 {
1684 return uint16(binary.LittleEndian.Uint16(v.raw[2:]))
1685}
1686func (v SetupView) ProtocolMinorVersion() uint16 {
1687 return uint16(binary.LittleEndian.Uint16(v.raw[4:]))
1688}
1689func (v SetupView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) }
1690func (v SetupView) ReleaseNumber() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) }
1691func (v SetupView) ResourceIdBase() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[12:])) }
1692func (v SetupView) ResourceIdMask() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[16:])) }
1693func (v SetupView) MotionBufferSize() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[20:])) }
1694func (v SetupView) VendorLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[24:])) }
1695func (v SetupView) MaximumRequestLength() uint16 {
1696 return uint16(binary.LittleEndian.Uint16(v.raw[26:]))
1697}
1698func (v SetupView) RootsLen() uint8 { return uint8(v.raw[28:][0]) }
1699func (v SetupView) PixmapFormatsLen() uint8 { return uint8(v.raw[29:][0]) }
1700func (v SetupView) ImageByteOrder() ImageOrder { return ImageOrder(v.raw[30:][0]) }
1701func (v SetupView) BitmapFormatBitOrder() ImageOrder { return ImageOrder(v.raw[31:][0]) }
1702func (v SetupView) BitmapFormatScanlineUnit() uint8 { return uint8(v.raw[32:][0]) }
1703func (v SetupView) BitmapFormatScanlinePad() uint8 { return uint8(v.raw[33:][0]) }
1704func (v SetupView) MinKeycode() Keycode { return Keycode(v.raw[34:][0]) }
1705func (v SetupView) MaxKeycode() Keycode { return Keycode(v.raw[35:][0]) }
1706func (v SetupView) Vendor() []byte {
1707 off := 40
1708 end := off + int(v.VendorLen())
1709 return v.raw[off:end:end]
1710}
1711func (v SetupView) PixmapFormats() FormatList {
1712 off := 40
1713 {
1714 n := int(v.VendorLen())
1715 off += n * 1
1716 }
1717 off = (off + 3) &^ 3
1718 end := off + (int(v.PixmapFormatsLen()))*8
1719 return FormatList{b: v.raw[off:end:end]}
1720}
1721func (v SetupView) Roots() ScreenIter {
1722 off := 40
1723 {
1724 n := int(v.VendorLen())
1725 off += n * 1
1726 }
1727 off = (off + 3) &^ 3
1728 {
1729 n := int(v.PixmapFormatsLen())
1730 off += n * 8
1731 }
1732 return NewScreenIter(v.raw[off:], int(v.RootsLen()))
1733}
1734
1735// SetupIter walks n consecutive Setup elements; Err reports a malformed length.
1736// It shares the lifetime of the bytes it walks.
1737type SetupIter struct {
1738 b []byte
1739 n int
1740 v SetupView
1741 err bool
1742}
1743
1744// NewSetupIter iterates n elements encoded at the start of b.
1745func NewSetupIter(b []byte, n int) SetupIter { return SetupIter{b: b, n: n} }
1746func (it *SetupIter) Next() bool {
1747 if it.n <= 0 || it.err {
1748 return false
1749 }
1750 s := sizeSetup(it.b)
1751 if s < 0 {
1752 it.err = true
1753 it.n = 0
1754 return false
1755 }
1756 it.v = SetupView{raw: it.b[:s:s]}
1757 it.b = it.b[s:]
1758 it.n--
1759 return true
1760}
1761func (it *SetupIter) Value() SetupView { return it.v }
1762func (it *SetupIter) Err() bool { return it.err }
1763
1764// StrView is a zero-copy view over one wire-encoded Str, yielded by StrIter.
1765// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1766type StrView struct{ raw []byte }
1767
1768func (v StrView) Raw() []byte { return v.raw }
1769
1770// Size is the element's wire size, including trailing alignment.
1771func (v StrView) Size() int { return len(v.raw) }
1772func sizeStr(p []byte) int {
1773 if len(p) < 1 {
1774 return -1
1775 }
1776 v := StrView{raw: p}
1777 _ = v
1778 off := 1
1779 {
1780 n := int(v.NameLen())
1781 if n < 0 || n > len(v.raw) {
1782 return -1
1783 }
1784 off += n * 1
1785 }
1786 if off > len(v.raw) {
1787 return -1
1788 }
1789 if off > len(v.raw) {
1790 return -1
1791 }
1792 return off
1793}
1794func (v StrView) NameLen() uint8 { return uint8(v.raw[0:][0]) }
1795func (v StrView) Name() []byte { off := 1; end := off + int(v.NameLen()); return v.raw[off:end:end] }
1796
1797// StrIter walks n consecutive Str elements; Err reports a malformed length.
1798// It shares the lifetime of the bytes it walks.
1799type StrIter struct {
1800 b []byte
1801 n int
1802 v StrView
1803 err bool
1804}
1805
1806// NewStrIter iterates n elements encoded at the start of b.
1807func NewStrIter(b []byte, n int) StrIter { return StrIter{b: b, n: n} }
1808func (it *StrIter) Next() bool {
1809 if it.n <= 0 || it.err {
1810 return false
1811 }
1812 s := sizeStr(it.b)
1813 if s < 0 {
1814 it.err = true
1815 it.n = 0
1816 return false
1817 }
1818 it.v = StrView{raw: it.b[:s:s]}
1819 it.b = it.b[s:]
1820 it.n--
1821 return true
1822}
1823func (it *StrIter) Value() StrView { return it.v }
1824func (it *StrIter) Err() bool { return it.err }
1825
1826// HostView is a zero-copy view over one wire-encoded Host, yielded by HostIter.
1827// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
1828type HostView struct{ raw []byte }
1829
1830func (v HostView) Raw() []byte { return v.raw }
1831
1832// Size is the element's wire size, including trailing alignment.
1833func (v HostView) Size() int { return len(v.raw) }
1834func sizeHost(p []byte) int {
1835 if len(p) < 4 {
1836 return -1
1837 }
1838 v := HostView{raw: p}
1839 _ = v
1840 off := 4
1841 {
1842 n := int(v.AddressLen())
1843 if n < 0 || n > len(v.raw) {
1844 return -1
1845 }
1846 off += n * 1
1847 }
1848 if off > len(v.raw) {
1849 return -1
1850 }
1851 off = (off + 3) &^ 3
1852 if off > len(v.raw) {
1853 return -1
1854 }
1855 return off
1856}
1857func (v HostView) Family() Family { return Family(v.raw[0:][0]) }
1858func (v HostView) AddressLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) }
1859func (v HostView) Address() []byte {
1860 off := 4
1861 end := off + int(v.AddressLen())
1862 return v.raw[off:end:end]
1863}
1864
1865// HostIter walks n consecutive Host elements; Err reports a malformed length.
1866// It shares the lifetime of the bytes it walks.
1867type HostIter struct {
1868 b []byte
1869 n int
1870 v HostView
1871 err bool
1872}
1873
1874// NewHostIter iterates n elements encoded at the start of b.
1875func NewHostIter(b []byte, n int) HostIter { return HostIter{b: b, n: n} }
1876func (it *HostIter) Next() bool {
1877 if it.n <= 0 || it.err {
1878 return false
1879 }
1880 s := sizeHost(it.b)
1881 if s < 0 {
1882 it.err = true
1883 it.n = 0
1884 return false
1885 }
1886 it.v = HostView{raw: it.b[:s:s]}
1887 it.b = it.b[s:]
1888 it.n--
1889 return true
1890}
1891func (it *HostIter) Value() HostView { return it.v }
1892func (it *HostIter) Err() bool { return it.err }
1893
1894// 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.
1895type AtomList struct{ b []byte }
1896
1897func (l AtomList) Len() int { return len(l.b) / 4 }
1898func (l AtomList) At(i int) Atom { return Atom(binary.LittleEndian.Uint32(l.b[i*4:])) }
1899
1900// 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.
1901type CharinfoList struct{ b []byte }
1902
1903func (l CharinfoList) Len() int { return len(l.b) / 12 }
1904func (l CharinfoList) At(i int) Charinfo { return GetCharinfo(l.b[i*12:]) }
1905
1906// 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.
1907type ColormapList struct{ b []byte }
1908
1909func (l ColormapList) Len() int { return len(l.b) / 4 }
1910func (l ColormapList) At(i int) Colormap { return Colormap(binary.LittleEndian.Uint32(l.b[i*4:])) }
1911
1912// 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.
1913type FontpropList struct{ b []byte }
1914
1915func (l FontpropList) Len() int { return len(l.b) / 8 }
1916func (l FontpropList) At(i int) Fontprop { return GetFontprop(l.b[i*8:]) }
1917
1918// 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.
1919type FormatList struct{ b []byte }
1920
1921func (l FormatList) Len() int { return len(l.b) / 8 }
1922func (l FormatList) At(i int) Format { return GetFormat(l.b[i*8:]) }
1923
1924// 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.
1925type KeycodeList struct{ b []byte }
1926
1927func (l KeycodeList) Len() int { return len(l.b) / 1 }
1928func (l KeycodeList) At(i int) Keycode { return Keycode(l.b[i*1:][0]) }
1929
1930// 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.
1931type KeysymList struct{ b []byte }
1932
1933func (l KeysymList) Len() int { return len(l.b) / 4 }
1934func (l KeysymList) At(i int) Keysym { return Keysym(binary.LittleEndian.Uint32(l.b[i*4:])) }
1935
1936// 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.
1937type RgbList struct{ b []byte }
1938
1939func (l RgbList) Len() int { return len(l.b) / 8 }
1940func (l RgbList) At(i int) Rgb { return GetRgb(l.b[i*8:]) }
1941
1942// 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.
1943type TimecoordList struct{ b []byte }
1944
1945func (l TimecoordList) Len() int { return len(l.b) / 8 }
1946func (l TimecoordList) At(i int) Timecoord { return GetTimecoord(l.b[i*8:]) }
1947
1948// 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.
1949type Uint32List struct{ b []byte }
1950
1951func (l Uint32List) Len() int { return len(l.b) / 4 }
1952func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) }
1953
1954// 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.
1955type VisualtypeList struct{ b []byte }
1956
1957func (l VisualtypeList) Len() int { return len(l.b) / 24 }
1958func (l VisualtypeList) At(i int) Visualtype { return GetVisualtype(l.b[i*24:]) }
1959
1960// 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.
1961type WindowList struct{ b []byte }
1962
1963func (l WindowList) Len() int { return len(l.b) / 4 }
1964func (l WindowList) At(i int) Window { return Window(binary.LittleEndian.Uint32(l.b[i*4:])) }