v0.1.0 602baa7

requests_generated.go RawHistoryFolder

1// Code generated by xtgen; DO NOT EDIT.
2package xproto
3
4import "encoding/binary"
5import "math/bits"
6import "bnema.dev/xturbo"
7
8type CreateWindowValues struct {
9	Mask               Cw
10	BackgroundPixmap   Pixmap
11	BackgroundPixel    uint32
12	BorderPixmap       Pixmap
13	BorderPixel        uint32
14	BitGravity         Gravity
15	WinGravity         Gravity
16	BackingStore       BackingStore
17	BackingPlanes      uint32
18	BackingPixel       uint32
19	OverrideRedirect   bool
20	SaveUnder          bool
21	EventMask          EventMask
22	DoNotPropogateMask EventMask
23	Colormap           Colormap
24	Cursor             Cursor
25}
26
27func (v *CreateWindowValues) SetBackgroundPixmap(x Pixmap) *CreateWindowValues {
28	v.Mask |= CwBackPixmap
29	v.BackgroundPixmap = x
30	return v
31}
32func (v *CreateWindowValues) SetBackgroundPixel(x uint32) *CreateWindowValues {
33	v.Mask |= CwBackPixel
34	v.BackgroundPixel = x
35	return v
36}
37func (v *CreateWindowValues) SetBorderPixmap(x Pixmap) *CreateWindowValues {
38	v.Mask |= CwBorderPixmap
39	v.BorderPixmap = x
40	return v
41}
42func (v *CreateWindowValues) SetBorderPixel(x uint32) *CreateWindowValues {
43	v.Mask |= CwBorderPixel
44	v.BorderPixel = x
45	return v
46}
47func (v *CreateWindowValues) SetBitGravity(x Gravity) *CreateWindowValues {
48	v.Mask |= CwBitGravity
49	v.BitGravity = x
50	return v
51}
52func (v *CreateWindowValues) SetWinGravity(x Gravity) *CreateWindowValues {
53	v.Mask |= CwWinGravity
54	v.WinGravity = x
55	return v
56}
57func (v *CreateWindowValues) SetBackingStore(x BackingStore) *CreateWindowValues {
58	v.Mask |= CwBackingStore
59	v.BackingStore = x
60	return v
61}
62func (v *CreateWindowValues) SetBackingPlanes(x uint32) *CreateWindowValues {
63	v.Mask |= CwBackingPlanes
64	v.BackingPlanes = x
65	return v
66}
67func (v *CreateWindowValues) SetBackingPixel(x uint32) *CreateWindowValues {
68	v.Mask |= CwBackingPixel
69	v.BackingPixel = x
70	return v
71}
72func (v *CreateWindowValues) SetOverrideRedirect(x bool) *CreateWindowValues {
73	v.Mask |= CwOverrideRedirect
74	v.OverrideRedirect = x
75	return v
76}
77func (v *CreateWindowValues) SetSaveUnder(x bool) *CreateWindowValues {
78	v.Mask |= CwSaveUnder
79	v.SaveUnder = x
80	return v
81}
82func (v *CreateWindowValues) SetEventMask(x EventMask) *CreateWindowValues {
83	v.Mask |= CwEventMask
84	v.EventMask = x
85	return v
86}
87func (v *CreateWindowValues) SetDoNotPropogateMask(x EventMask) *CreateWindowValues {
88	v.Mask |= CwDontPropagate
89	v.DoNotPropogateMask = x
90	return v
91}
92func (v *CreateWindowValues) SetColormap(x Colormap) *CreateWindowValues {
93	v.Mask |= CwColormap
94	v.Colormap = x
95	return v
96}
97func (v *CreateWindowValues) SetCursor(x Cursor) *CreateWindowValues {
98	v.Mask |= CwCursor
99	v.Cursor = x
100	return v
101}
102func CreateWindow(b *xturbo.Buf, depth uint8, wid Window, parent Window, x int16, y int16, width uint16, height uint16, borderWidth uint16, class WindowClass, visual Visualid, v *CreateWindowValues) xturbo.Seq {
103	p, seq := b.Request(1, uint8(int(depth)), 28+4*bits.OnesCount32(uint32(v.Mask)))
104	if p == nil {
105		return 0
106	}
107	binary.LittleEndian.PutUint32(p[0:], uint32(wid))
108	binary.LittleEndian.PutUint32(p[4:], uint32(parent))
109	binary.LittleEndian.PutUint16(p[8:], uint16(x))
110	binary.LittleEndian.PutUint16(p[10:], uint16(y))
111	binary.LittleEndian.PutUint16(p[12:], uint16(width))
112	binary.LittleEndian.PutUint16(p[14:], uint16(height))
113	binary.LittleEndian.PutUint16(p[16:], uint16(borderWidth))
114	binary.LittleEndian.PutUint16(p[18:], uint16(class))
115	binary.LittleEndian.PutUint32(p[20:], uint32(visual))
116	binary.LittleEndian.PutUint32(p[24:], uint32(v.Mask))
117	off := 28
118	if v.Mask&CwBackPixmap != 0 {
119		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixmap))
120		off += 4
121	}
122	if v.Mask&CwBackPixel != 0 {
123		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixel))
124		off += 4
125	}
126	if v.Mask&CwBorderPixmap != 0 {
127		binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixmap))
128		off += 4
129	}
130	if v.Mask&CwBorderPixel != 0 {
131		binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixel))
132		off += 4
133	}
134	if v.Mask&CwBitGravity != 0 {
135		binary.LittleEndian.PutUint32(p[off:], uint32(v.BitGravity))
136		off += 4
137	}
138	if v.Mask&CwWinGravity != 0 {
139		binary.LittleEndian.PutUint32(p[off:], uint32(v.WinGravity))
140		off += 4
141	}
142	if v.Mask&CwBackingStore != 0 {
143		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingStore))
144		off += 4
145	}
146	if v.Mask&CwBackingPlanes != 0 {
147		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPlanes))
148		off += 4
149	}
150	if v.Mask&CwBackingPixel != 0 {
151		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPixel))
152		off += 4
153	}
154	if v.Mask&CwOverrideRedirect != 0 {
155		if v.OverrideRedirect {
156			binary.LittleEndian.PutUint32(p[off:], 1)
157		} else {
158			binary.LittleEndian.PutUint32(p[off:], 0)
159		}
160		off += 4
161	}
162	if v.Mask&CwSaveUnder != 0 {
163		if v.SaveUnder {
164			binary.LittleEndian.PutUint32(p[off:], 1)
165		} else {
166			binary.LittleEndian.PutUint32(p[off:], 0)
167		}
168		off += 4
169	}
170	if v.Mask&CwEventMask != 0 {
171		binary.LittleEndian.PutUint32(p[off:], uint32(v.EventMask))
172		off += 4
173	}
174	if v.Mask&CwDontPropagate != 0 {
175		binary.LittleEndian.PutUint32(p[off:], uint32(v.DoNotPropogateMask))
176		off += 4
177	}
178	if v.Mask&CwColormap != 0 {
179		binary.LittleEndian.PutUint32(p[off:], uint32(v.Colormap))
180		off += 4
181	}
182	if v.Mask&CwCursor != 0 {
183		binary.LittleEndian.PutUint32(p[off:], uint32(v.Cursor))
184		off += 4
185	}
186	_ = off
187	return seq
188}
189
190type ChangeWindowAttributesValues struct {
191	Mask               Cw
192	BackgroundPixmap   Pixmap
193	BackgroundPixel    uint32
194	BorderPixmap       Pixmap
195	BorderPixel        uint32
196	BitGravity         Gravity
197	WinGravity         Gravity
198	BackingStore       BackingStore
199	BackingPlanes      uint32
200	BackingPixel       uint32
201	OverrideRedirect   bool
202	SaveUnder          bool
203	EventMask          EventMask
204	DoNotPropogateMask EventMask
205	Colormap           Colormap
206	Cursor             Cursor
207}
208
209func (v *ChangeWindowAttributesValues) SetBackgroundPixmap(x Pixmap) *ChangeWindowAttributesValues {
210	v.Mask |= CwBackPixmap
211	v.BackgroundPixmap = x
212	return v
213}
214func (v *ChangeWindowAttributesValues) SetBackgroundPixel(x uint32) *ChangeWindowAttributesValues {
215	v.Mask |= CwBackPixel
216	v.BackgroundPixel = x
217	return v
218}
219func (v *ChangeWindowAttributesValues) SetBorderPixmap(x Pixmap) *ChangeWindowAttributesValues {
220	v.Mask |= CwBorderPixmap
221	v.BorderPixmap = x
222	return v
223}
224func (v *ChangeWindowAttributesValues) SetBorderPixel(x uint32) *ChangeWindowAttributesValues {
225	v.Mask |= CwBorderPixel
226	v.BorderPixel = x
227	return v
228}
229func (v *ChangeWindowAttributesValues) SetBitGravity(x Gravity) *ChangeWindowAttributesValues {
230	v.Mask |= CwBitGravity
231	v.BitGravity = x
232	return v
233}
234func (v *ChangeWindowAttributesValues) SetWinGravity(x Gravity) *ChangeWindowAttributesValues {
235	v.Mask |= CwWinGravity
236	v.WinGravity = x
237	return v
238}
239func (v *ChangeWindowAttributesValues) SetBackingStore(x BackingStore) *ChangeWindowAttributesValues {
240	v.Mask |= CwBackingStore
241	v.BackingStore = x
242	return v
243}
244func (v *ChangeWindowAttributesValues) SetBackingPlanes(x uint32) *ChangeWindowAttributesValues {
245	v.Mask |= CwBackingPlanes
246	v.BackingPlanes = x
247	return v
248}
249func (v *ChangeWindowAttributesValues) SetBackingPixel(x uint32) *ChangeWindowAttributesValues {
250	v.Mask |= CwBackingPixel
251	v.BackingPixel = x
252	return v
253}
254func (v *ChangeWindowAttributesValues) SetOverrideRedirect(x bool) *ChangeWindowAttributesValues {
255	v.Mask |= CwOverrideRedirect
256	v.OverrideRedirect = x
257	return v
258}
259func (v *ChangeWindowAttributesValues) SetSaveUnder(x bool) *ChangeWindowAttributesValues {
260	v.Mask |= CwSaveUnder
261	v.SaveUnder = x
262	return v
263}
264func (v *ChangeWindowAttributesValues) SetEventMask(x EventMask) *ChangeWindowAttributesValues {
265	v.Mask |= CwEventMask
266	v.EventMask = x
267	return v
268}
269func (v *ChangeWindowAttributesValues) SetDoNotPropogateMask(x EventMask) *ChangeWindowAttributesValues {
270	v.Mask |= CwDontPropagate
271	v.DoNotPropogateMask = x
272	return v
273}
274func (v *ChangeWindowAttributesValues) SetColormap(x Colormap) *ChangeWindowAttributesValues {
275	v.Mask |= CwColormap
276	v.Colormap = x
277	return v
278}
279func (v *ChangeWindowAttributesValues) SetCursor(x Cursor) *ChangeWindowAttributesValues {
280	v.Mask |= CwCursor
281	v.Cursor = x
282	return v
283}
284func ChangeWindowAttributes(b *xturbo.Buf, window Window, v *ChangeWindowAttributesValues) xturbo.Seq {
285	p, seq := b.Request(2, 0, 8+4*bits.OnesCount32(uint32(v.Mask)))
286	if p == nil {
287		return 0
288	}
289	binary.LittleEndian.PutUint32(p[0:], uint32(window))
290	binary.LittleEndian.PutUint32(p[4:], uint32(v.Mask))
291	off := 8
292	if v.Mask&CwBackPixmap != 0 {
293		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixmap))
294		off += 4
295	}
296	if v.Mask&CwBackPixel != 0 {
297		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixel))
298		off += 4
299	}
300	if v.Mask&CwBorderPixmap != 0 {
301		binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixmap))
302		off += 4
303	}
304	if v.Mask&CwBorderPixel != 0 {
305		binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixel))
306		off += 4
307	}
308	if v.Mask&CwBitGravity != 0 {
309		binary.LittleEndian.PutUint32(p[off:], uint32(v.BitGravity))
310		off += 4
311	}
312	if v.Mask&CwWinGravity != 0 {
313		binary.LittleEndian.PutUint32(p[off:], uint32(v.WinGravity))
314		off += 4
315	}
316	if v.Mask&CwBackingStore != 0 {
317		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingStore))
318		off += 4
319	}
320	if v.Mask&CwBackingPlanes != 0 {
321		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPlanes))
322		off += 4
323	}
324	if v.Mask&CwBackingPixel != 0 {
325		binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPixel))
326		off += 4
327	}
328	if v.Mask&CwOverrideRedirect != 0 {
329		if v.OverrideRedirect {
330			binary.LittleEndian.PutUint32(p[off:], 1)
331		} else {
332			binary.LittleEndian.PutUint32(p[off:], 0)
333		}
334		off += 4
335	}
336	if v.Mask&CwSaveUnder != 0 {
337		if v.SaveUnder {
338			binary.LittleEndian.PutUint32(p[off:], 1)
339		} else {
340			binary.LittleEndian.PutUint32(p[off:], 0)
341		}
342		off += 4
343	}
344	if v.Mask&CwEventMask != 0 {
345		binary.LittleEndian.PutUint32(p[off:], uint32(v.EventMask))
346		off += 4
347	}
348	if v.Mask&CwDontPropagate != 0 {
349		binary.LittleEndian.PutUint32(p[off:], uint32(v.DoNotPropogateMask))
350		off += 4
351	}
352	if v.Mask&CwColormap != 0 {
353		binary.LittleEndian.PutUint32(p[off:], uint32(v.Colormap))
354		off += 4
355	}
356	if v.Mask&CwCursor != 0 {
357		binary.LittleEndian.PutUint32(p[off:], uint32(v.Cursor))
358		off += 4
359	}
360	_ = off
361	return seq
362}
363
364func GetWindowAttributes(b *xturbo.Buf, window Window) xturbo.Seq {
365	p, seq := b.Request(3, 0, 4)
366	if p == nil {
367		return 0
368	}
369	binary.LittleEndian.PutUint32(p[0:], uint32(window))
370	return seq
371}
372
373func DestroyWindow(b *xturbo.Buf, window Window) xturbo.Seq {
374	p, seq := b.Request(4, 0, 4)
375	if p == nil {
376		return 0
377	}
378	binary.LittleEndian.PutUint32(p[0:], uint32(window))
379	return seq
380}
381
382func DestroySubwindows(b *xturbo.Buf, window Window) xturbo.Seq {
383	p, seq := b.Request(5, 0, 4)
384	if p == nil {
385		return 0
386	}
387	binary.LittleEndian.PutUint32(p[0:], uint32(window))
388	return seq
389}
390
391func ChangeSaveSet(b *xturbo.Buf, mode SetMode, window Window) xturbo.Seq {
392	p, seq := b.Request(6, uint8(int(mode)), 4)
393	if p == nil {
394		return 0
395	}
396	binary.LittleEndian.PutUint32(p[0:], uint32(window))
397	return seq
398}
399
400func ReparentWindow(b *xturbo.Buf, window Window, parent Window, x int16, y int16) xturbo.Seq {
401	p, seq := b.Request(7, 0, 12)
402	if p == nil {
403		return 0
404	}
405	binary.LittleEndian.PutUint32(p[0:], uint32(window))
406	binary.LittleEndian.PutUint32(p[4:], uint32(parent))
407	binary.LittleEndian.PutUint16(p[8:], uint16(x))
408	binary.LittleEndian.PutUint16(p[10:], uint16(y))
409	return seq
410}
411
412func MapWindow(b *xturbo.Buf, window Window) xturbo.Seq {
413	p, seq := b.Request(8, 0, 4)
414	if p == nil {
415		return 0
416	}
417	binary.LittleEndian.PutUint32(p[0:], uint32(window))
418	return seq
419}
420
421func MapSubwindows(b *xturbo.Buf, window Window) xturbo.Seq {
422	p, seq := b.Request(9, 0, 4)
423	if p == nil {
424		return 0
425	}
426	binary.LittleEndian.PutUint32(p[0:], uint32(window))
427	return seq
428}
429
430func UnmapWindow(b *xturbo.Buf, window Window) xturbo.Seq {
431	p, seq := b.Request(10, 0, 4)
432	if p == nil {
433		return 0
434	}
435	binary.LittleEndian.PutUint32(p[0:], uint32(window))
436	return seq
437}
438
439func UnmapSubwindows(b *xturbo.Buf, window Window) xturbo.Seq {
440	p, seq := b.Request(11, 0, 4)
441	if p == nil {
442		return 0
443	}
444	binary.LittleEndian.PutUint32(p[0:], uint32(window))
445	return seq
446}
447
448type ConfigureWindowValues struct {
449	Mask        ConfigWindow
450	X           int32
451	Y           int32
452	Width       uint32
453	Height      uint32
454	BorderWidth uint32
455	Sibling     Window
456	StackMode   StackMode
457}
458
459func (v *ConfigureWindowValues) SetX(x int32) *ConfigureWindowValues {
460	v.Mask |= ConfigWindowX
461	v.X = x
462	return v
463}
464func (v *ConfigureWindowValues) SetY(x int32) *ConfigureWindowValues {
465	v.Mask |= ConfigWindowY
466	v.Y = x
467	return v
468}
469func (v *ConfigureWindowValues) SetWidth(x uint32) *ConfigureWindowValues {
470	v.Mask |= ConfigWindowWidth
471	v.Width = x
472	return v
473}
474func (v *ConfigureWindowValues) SetHeight(x uint32) *ConfigureWindowValues {
475	v.Mask |= ConfigWindowHeight
476	v.Height = x
477	return v
478}
479func (v *ConfigureWindowValues) SetBorderWidth(x uint32) *ConfigureWindowValues {
480	v.Mask |= ConfigWindowBorderWidth
481	v.BorderWidth = x
482	return v
483}
484func (v *ConfigureWindowValues) SetSibling(x Window) *ConfigureWindowValues {
485	v.Mask |= ConfigWindowSibling
486	v.Sibling = x
487	return v
488}
489func (v *ConfigureWindowValues) SetStackMode(x StackMode) *ConfigureWindowValues {
490	v.Mask |= ConfigWindowStackMode
491	v.StackMode = x
492	return v
493}
494func ConfigureWindow(b *xturbo.Buf, window Window, v *ConfigureWindowValues) xturbo.Seq {
495	p, seq := b.Request(12, 0, 8+4*bits.OnesCount32(uint32(v.Mask)))
496	if p == nil {
497		return 0
498	}
499	binary.LittleEndian.PutUint32(p[0:], uint32(window))
500	binary.LittleEndian.PutUint16(p[4:], uint16(v.Mask))
501	off := 8
502	if v.Mask&ConfigWindowX != 0 {
503		binary.LittleEndian.PutUint32(p[off:], uint32(v.X))
504		off += 4
505	}
506	if v.Mask&ConfigWindowY != 0 {
507		binary.LittleEndian.PutUint32(p[off:], uint32(v.Y))
508		off += 4
509	}
510	if v.Mask&ConfigWindowWidth != 0 {
511		binary.LittleEndian.PutUint32(p[off:], uint32(v.Width))
512		off += 4
513	}
514	if v.Mask&ConfigWindowHeight != 0 {
515		binary.LittleEndian.PutUint32(p[off:], uint32(v.Height))
516		off += 4
517	}
518	if v.Mask&ConfigWindowBorderWidth != 0 {
519		binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderWidth))
520		off += 4
521	}
522	if v.Mask&ConfigWindowSibling != 0 {
523		binary.LittleEndian.PutUint32(p[off:], uint32(v.Sibling))
524		off += 4
525	}
526	if v.Mask&ConfigWindowStackMode != 0 {
527		binary.LittleEndian.PutUint32(p[off:], uint32(v.StackMode))
528		off += 4
529	}
530	_ = off
531	return seq
532}
533
534func CirculateWindow(b *xturbo.Buf, direction Circulate, window Window) xturbo.Seq {
535	p, seq := b.Request(13, uint8(int(direction)), 4)
536	if p == nil {
537		return 0
538	}
539	binary.LittleEndian.PutUint32(p[0:], uint32(window))
540	return seq
541}
542
543func GetGeometry(b *xturbo.Buf, drawable Drawable) xturbo.Seq {
544	p, seq := b.Request(14, 0, 4)
545	if p == nil {
546		return 0
547	}
548	binary.LittleEndian.PutUint32(p[0:], uint32(drawable))
549	return seq
550}
551
552func QueryTree(b *xturbo.Buf, window Window) xturbo.Seq {
553	p, seq := b.Request(15, 0, 4)
554	if p == nil {
555		return 0
556	}
557	binary.LittleEndian.PutUint32(p[0:], uint32(window))
558	return seq
559}
560
561func InternAtom(b *xturbo.Buf, onlyIfExists bool, name string) xturbo.Seq {
562	if uint64(len(name)) > 65535 {
563		b.Fail(xturbo.ErrBadLength)
564		return 0
565	}
566	size := 0
567	size += 2
568	size += 2
569	size += len(name) * 1
570	size = (size + 3) &^ 3
571	var data uint8
572	if onlyIfExists {
573		data = 1
574	}
575	p, seq := b.Request(16, data, size)
576	if p == nil {
577		return 0
578	}
579	off := 0
580	binary.LittleEndian.PutUint16(p[off:], uint16(len(name)))
581	off += 2
582	off += 2
583	copy(p[off:], name)
584	off += len(name)
585	return seq
586}
587
588func GetAtomName(b *xturbo.Buf, atom Atom) xturbo.Seq {
589	p, seq := b.Request(17, 0, 4)
590	if p == nil {
591		return 0
592	}
593	binary.LittleEndian.PutUint32(p[0:], uint32(atom))
594	return seq
595}
596
597func ChangeProperty(b *xturbo.Buf, mode PropMode, window Window, property Atom, type_ Atom, format uint8, dataLen uint32, data []byte) xturbo.Seq {
598	if len(data) != ((int(dataLen) * int(format)) / 8) {
599		b.Fail(xturbo.ErrBadLength)
600		return 0
601	}
602	size := 0
603	size += 4
604	size += 4
605	size += 4
606	size += 1
607	size += 3
608	size += 4
609	size += len(data) * 1
610	size = (size + 3) &^ 3
611	p, seq := b.Request(18, uint8(int(mode)), size)
612	if p == nil {
613		return 0
614	}
615	off := 0
616	binary.LittleEndian.PutUint32(p[off:], uint32(window))
617	off += 4
618	binary.LittleEndian.PutUint32(p[off:], uint32(property))
619	off += 4
620	binary.LittleEndian.PutUint32(p[off:], uint32(type_))
621	off += 4
622	p[off:][0] = byte(format)
623	off += 1
624	off += 3
625	binary.LittleEndian.PutUint32(p[off:], uint32(dataLen))
626	off += 4
627	copy(p[off:], data)
628	off += len(data)
629	return seq
630}
631
632func DeleteProperty(b *xturbo.Buf, window Window, property Atom) xturbo.Seq {
633	p, seq := b.Request(19, 0, 8)
634	if p == nil {
635		return 0
636	}
637	binary.LittleEndian.PutUint32(p[0:], uint32(window))
638	binary.LittleEndian.PutUint32(p[4:], uint32(property))
639	return seq
640}
641
642func GetProperty(b *xturbo.Buf, delete bool, window Window, property Atom, type_ Atom, longOffset uint32, longLength uint32) xturbo.Seq {
643	var data uint8
644	if delete {
645		data = 1
646	}
647	p, seq := b.Request(20, data, 20)
648	if p == nil {
649		return 0
650	}
651	binary.LittleEndian.PutUint32(p[0:], uint32(window))
652	binary.LittleEndian.PutUint32(p[4:], uint32(property))
653	binary.LittleEndian.PutUint32(p[8:], uint32(type_))
654	binary.LittleEndian.PutUint32(p[12:], uint32(longOffset))
655	binary.LittleEndian.PutUint32(p[16:], uint32(longLength))
656	return seq
657}
658
659func ListProperties(b *xturbo.Buf, window Window) xturbo.Seq {
660	p, seq := b.Request(21, 0, 4)
661	if p == nil {
662		return 0
663	}
664	binary.LittleEndian.PutUint32(p[0:], uint32(window))
665	return seq
666}
667
668func SetSelectionOwner(b *xturbo.Buf, owner Window, selection Atom, time Timestamp) xturbo.Seq {
669	p, seq := b.Request(22, 0, 12)
670	if p == nil {
671		return 0
672	}
673	binary.LittleEndian.PutUint32(p[0:], uint32(owner))
674	binary.LittleEndian.PutUint32(p[4:], uint32(selection))
675	binary.LittleEndian.PutUint32(p[8:], uint32(time))
676	return seq
677}
678
679func GetSelectionOwner(b *xturbo.Buf, selection Atom) xturbo.Seq {
680	p, seq := b.Request(23, 0, 4)
681	if p == nil {
682		return 0
683	}
684	binary.LittleEndian.PutUint32(p[0:], uint32(selection))
685	return seq
686}
687
688func ConvertSelection(b *xturbo.Buf, requestor Window, selection Atom, target Atom, property Atom, time Timestamp) xturbo.Seq {
689	p, seq := b.Request(24, 0, 20)
690	if p == nil {
691		return 0
692	}
693	binary.LittleEndian.PutUint32(p[0:], uint32(requestor))
694	binary.LittleEndian.PutUint32(p[4:], uint32(selection))
695	binary.LittleEndian.PutUint32(p[8:], uint32(target))
696	binary.LittleEndian.PutUint32(p[12:], uint32(property))
697	binary.LittleEndian.PutUint32(p[16:], uint32(time))
698	return seq
699}
700
701func SendEvent(b *xturbo.Buf, propagate bool, destination Window, eventMask EventMask, event *[32]byte) xturbo.Seq {
702	if len(event) != 32 {
703		b.Fail(xturbo.ErrBadLength)
704		return 0
705	}
706	size := 0
707	size += 4
708	size += 4
709	size += len(event) * 1
710	size = (size + 3) &^ 3
711	var data uint8
712	if propagate {
713		data = 1
714	}
715	p, seq := b.Request(25, data, size)
716	if p == nil {
717		return 0
718	}
719	off := 0
720	binary.LittleEndian.PutUint32(p[off:], uint32(destination))
721	off += 4
722	binary.LittleEndian.PutUint32(p[off:], uint32(eventMask))
723	off += 4
724	copy(p[off:], event[:])
725	return seq
726}
727
728func GrabPointer(b *xturbo.Buf, ownerEvents bool, grabWindow Window, eventMask EventMask, pointerMode GrabMode, keyboardMode GrabMode, confineTo Window, cursor Cursor, time Timestamp) xturbo.Seq {
729	var data uint8
730	if ownerEvents {
731		data = 1
732	}
733	p, seq := b.Request(26, data, 20)
734	if p == nil {
735		return 0
736	}
737	binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow))
738	binary.LittleEndian.PutUint16(p[4:], uint16(eventMask))
739	p[6:][0] = byte(pointerMode)
740	p[7:][0] = byte(keyboardMode)
741	binary.LittleEndian.PutUint32(p[8:], uint32(confineTo))
742	binary.LittleEndian.PutUint32(p[12:], uint32(cursor))
743	binary.LittleEndian.PutUint32(p[16:], uint32(time))
744	return seq
745}
746
747func UngrabPointer(b *xturbo.Buf, time Timestamp) xturbo.Seq {
748	p, seq := b.Request(27, 0, 4)
749	if p == nil {
750		return 0
751	}
752	binary.LittleEndian.PutUint32(p[0:], uint32(time))
753	return seq
754}
755
756func GrabButton(b *xturbo.Buf, ownerEvents bool, grabWindow Window, eventMask EventMask, pointerMode GrabMode, keyboardMode GrabMode, confineTo Window, cursor Cursor, button ButtonIndex, modifiers ModMask) xturbo.Seq {
757	var data uint8
758	if ownerEvents {
759		data = 1
760	}
761	p, seq := b.Request(28, data, 20)
762	if p == nil {
763		return 0
764	}
765	binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow))
766	binary.LittleEndian.PutUint16(p[4:], uint16(eventMask))
767	p[6:][0] = byte(pointerMode)
768	p[7:][0] = byte(keyboardMode)
769	binary.LittleEndian.PutUint32(p[8:], uint32(confineTo))
770	binary.LittleEndian.PutUint32(p[12:], uint32(cursor))
771	p[16:][0] = byte(button)
772	binary.LittleEndian.PutUint16(p[18:], uint16(modifiers))
773	return seq
774}
775
776func UngrabButton(b *xturbo.Buf, button ButtonIndex, grabWindow Window, modifiers ModMask) xturbo.Seq {
777	p, seq := b.Request(29, uint8(int(button)), 8)
778	if p == nil {
779		return 0
780	}
781	binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow))
782	binary.LittleEndian.PutUint16(p[4:], uint16(modifiers))
783	return seq
784}
785
786func ChangeActivePointerGrab(b *xturbo.Buf, cursor Cursor, time Timestamp, eventMask EventMask) xturbo.Seq {
787	p, seq := b.Request(30, 0, 12)
788	if p == nil {
789		return 0
790	}
791	binary.LittleEndian.PutUint32(p[0:], uint32(cursor))
792	binary.LittleEndian.PutUint32(p[4:], uint32(time))
793	binary.LittleEndian.PutUint16(p[8:], uint16(eventMask))
794	return seq
795}
796
797func GrabKeyboard(b *xturbo.Buf, ownerEvents bool, grabWindow Window, time Timestamp, pointerMode GrabMode, keyboardMode GrabMode) xturbo.Seq {
798	var data uint8
799	if ownerEvents {
800		data = 1
801	}
802	p, seq := b.Request(31, data, 12)
803	if p == nil {
804		return 0
805	}
806	binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow))
807	binary.LittleEndian.PutUint32(p[4:], uint32(time))
808	p[8:][0] = byte(pointerMode)
809	p[9:][0] = byte(keyboardMode)
810	return seq
811}
812
813func UngrabKeyboard(b *xturbo.Buf, time Timestamp) xturbo.Seq {
814	p, seq := b.Request(32, 0, 4)
815	if p == nil {
816		return 0
817	}
818	binary.LittleEndian.PutUint32(p[0:], uint32(time))
819	return seq
820}
821
822func GrabKey(b *xturbo.Buf, ownerEvents bool, grabWindow Window, modifiers ModMask, key Keycode, pointerMode GrabMode, keyboardMode GrabMode) xturbo.Seq {
823	var data uint8
824	if ownerEvents {
825		data = 1
826	}
827	p, seq := b.Request(33, data, 12)
828	if p == nil {
829		return 0
830	}
831	binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow))
832	binary.LittleEndian.PutUint16(p[4:], uint16(modifiers))
833	p[6:][0] = byte(key)
834	p[7:][0] = byte(pointerMode)
835	p[8:][0] = byte(keyboardMode)
836	return seq
837}
838
839func UngrabKey(b *xturbo.Buf, key Keycode, grabWindow Window, modifiers ModMask) xturbo.Seq {
840	p, seq := b.Request(34, uint8(int(key)), 8)
841	if p == nil {
842		return 0
843	}
844	binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow))
845	binary.LittleEndian.PutUint16(p[4:], uint16(modifiers))
846	return seq
847}
848
849func AllowEvents(b *xturbo.Buf, mode Allow, time Timestamp) xturbo.Seq {
850	p, seq := b.Request(35, uint8(int(mode)), 4)
851	if p == nil {
852		return 0
853	}
854	binary.LittleEndian.PutUint32(p[0:], uint32(time))
855	return seq
856}
857
858func GrabServer(b *xturbo.Buf) xturbo.Seq {
859	p, seq := b.Request(36, 0, 0)
860	if p == nil {
861		return 0
862	}
863	return seq
864}
865
866func UngrabServer(b *xturbo.Buf) xturbo.Seq {
867	p, seq := b.Request(37, 0, 0)
868	if p == nil {
869		return 0
870	}
871	return seq
872}
873
874func QueryPointer(b *xturbo.Buf, window Window) xturbo.Seq {
875	p, seq := b.Request(38, 0, 4)
876	if p == nil {
877		return 0
878	}
879	binary.LittleEndian.PutUint32(p[0:], uint32(window))
880	return seq
881}
882
883func GetMotionEvents(b *xturbo.Buf, window Window, start Timestamp, stop Timestamp) xturbo.Seq {
884	p, seq := b.Request(39, 0, 12)
885	if p == nil {
886		return 0
887	}
888	binary.LittleEndian.PutUint32(p[0:], uint32(window))
889	binary.LittleEndian.PutUint32(p[4:], uint32(start))
890	binary.LittleEndian.PutUint32(p[8:], uint32(stop))
891	return seq
892}
893
894func TranslateCoordinates(b *xturbo.Buf, srcWindow Window, dstWindow Window, srcX int16, srcY int16) xturbo.Seq {
895	p, seq := b.Request(40, 0, 12)
896	if p == nil {
897		return 0
898	}
899	binary.LittleEndian.PutUint32(p[0:], uint32(srcWindow))
900	binary.LittleEndian.PutUint32(p[4:], uint32(dstWindow))
901	binary.LittleEndian.PutUint16(p[8:], uint16(srcX))
902	binary.LittleEndian.PutUint16(p[10:], uint16(srcY))
903	return seq
904}
905
906func WarpPointer(b *xturbo.Buf, srcWindow Window, dstWindow Window, srcX int16, srcY int16, srcWidth uint16, srcHeight uint16, dstX int16, dstY int16) xturbo.Seq {
907	p, seq := b.Request(41, 0, 20)
908	if p == nil {
909		return 0
910	}
911	binary.LittleEndian.PutUint32(p[0:], uint32(srcWindow))
912	binary.LittleEndian.PutUint32(p[4:], uint32(dstWindow))
913	binary.LittleEndian.PutUint16(p[8:], uint16(srcX))
914	binary.LittleEndian.PutUint16(p[10:], uint16(srcY))
915	binary.LittleEndian.PutUint16(p[12:], uint16(srcWidth))
916	binary.LittleEndian.PutUint16(p[14:], uint16(srcHeight))
917	binary.LittleEndian.PutUint16(p[16:], uint16(dstX))
918	binary.LittleEndian.PutUint16(p[18:], uint16(dstY))
919	return seq
920}
921
922func SetInputFocus(b *xturbo.Buf, revertTo InputFocus, focus Window, time Timestamp) xturbo.Seq {
923	p, seq := b.Request(42, uint8(int(revertTo)), 8)
924	if p == nil {
925		return 0
926	}
927	binary.LittleEndian.PutUint32(p[0:], uint32(focus))
928	binary.LittleEndian.PutUint32(p[4:], uint32(time))
929	return seq
930}
931
932func GetInputFocus(b *xturbo.Buf) xturbo.Seq {
933	p, seq := b.Request(43, 0, 0)
934	if p == nil {
935		return 0
936	}
937	return seq
938}
939
940func QueryKeymap(b *xturbo.Buf) xturbo.Seq {
941	p, seq := b.Request(44, 0, 0)
942	if p == nil {
943		return 0
944	}
945	return seq
946}
947
948func OpenFont(b *xturbo.Buf, fid Font, name string) xturbo.Seq {
949	if uint64(len(name)) > 65535 {
950		b.Fail(xturbo.ErrBadLength)
951		return 0
952	}
953	size := 0
954	size += 4
955	size += 2
956	size += 2
957	size += len(name) * 1
958	size = (size + 3) &^ 3
959	p, seq := b.Request(45, 0, size)
960	if p == nil {
961		return 0
962	}
963	off := 0
964	binary.LittleEndian.PutUint32(p[off:], uint32(fid))
965	off += 4
966	binary.LittleEndian.PutUint16(p[off:], uint16(len(name)))
967	off += 2
968	off += 2
969	copy(p[off:], name)
970	off += len(name)
971	return seq
972}
973
974func CloseFont(b *xturbo.Buf, font Font) xturbo.Seq {
975	p, seq := b.Request(46, 0, 4)
976	if p == nil {
977		return 0
978	}
979	binary.LittleEndian.PutUint32(p[0:], uint32(font))
980	return seq
981}
982
983func QueryFont(b *xturbo.Buf, font Fontable) xturbo.Seq {
984	p, seq := b.Request(47, 0, 4)
985	if p == nil {
986		return 0
987	}
988	binary.LittleEndian.PutUint32(p[0:], uint32(font))
989	return seq
990}
991
992func QueryTextExtents(b *xturbo.Buf, font Fontable, string []Char2b) xturbo.Seq {
993	size := 0
994	size += 4
995	size += len(string) * 2
996	size = (size + 3) &^ 3
997	var data uint8
998	if (len(string) & 1) != 0 {
999		data = 1
1000	}
1001	p, seq := b.Request(48, data, size)
1002	if p == nil {
1003		return 0
1004	}
1005	off := 0
1006	binary.LittleEndian.PutUint32(p[off:], uint32(font))
1007	off += 4
1008	for i := range string {
1009		string[i].Put(p[off:])
1010		off += 2
1011	}
1012	return seq
1013}
1014
1015func ListFonts(b *xturbo.Buf, maxNames uint16, pattern string) xturbo.Seq {
1016	if uint64(len(pattern)) > 65535 {
1017		b.Fail(xturbo.ErrBadLength)
1018		return 0
1019	}
1020	size := 0
1021	size += 2
1022	size += 2
1023	size += len(pattern) * 1
1024	size = (size + 3) &^ 3
1025	p, seq := b.Request(49, 0, size)
1026	if p == nil {
1027		return 0
1028	}
1029	off := 0
1030	binary.LittleEndian.PutUint16(p[off:], uint16(maxNames))
1031	off += 2
1032	binary.LittleEndian.PutUint16(p[off:], uint16(len(pattern)))
1033	off += 2
1034	copy(p[off:], pattern)
1035	off += len(pattern)
1036	return seq
1037}
1038
1039func ListFontsWithInfo(b *xturbo.Buf, maxNames uint16, pattern string) xturbo.Seq {
1040	if uint64(len(pattern)) > 65535 {
1041		b.Fail(xturbo.ErrBadLength)
1042		return 0
1043	}
1044	size := 0
1045	size += 2
1046	size += 2
1047	size += len(pattern) * 1
1048	size = (size + 3) &^ 3
1049	p, seq := b.Request(50, 0, size)
1050	if p == nil {
1051		return 0
1052	}
1053	off := 0
1054	binary.LittleEndian.PutUint16(p[off:], uint16(maxNames))
1055	off += 2
1056	binary.LittleEndian.PutUint16(p[off:], uint16(len(pattern)))
1057	off += 2
1058	copy(p[off:], pattern)
1059	off += len(pattern)
1060	return seq
1061}
1062
1063func SetFontPath(b *xturbo.Buf, font []Str) xturbo.Seq {
1064	if uint64(len(font)) > 65535 {
1065		b.Fail(xturbo.ErrBadLength)
1066		return 0
1067	}
1068	size := 0
1069	size += 2
1070	size += 2
1071	for i := range font {
1072		size += font[i].Size()
1073	}
1074	size = (size + 3) &^ 3
1075	p, seq := b.Request(51, 0, size)
1076	if p == nil {
1077		return 0
1078	}
1079	off := 0
1080	binary.LittleEndian.PutUint16(p[off:], uint16(len(font)))
1081	off += 2
1082	off += 2
1083	for i := range font {
1084		font[i].Put(p[off:])
1085		off += font[i].Size()
1086	}
1087	return seq
1088}
1089
1090func GetFontPath(b *xturbo.Buf) xturbo.Seq {
1091	p, seq := b.Request(52, 0, 0)
1092	if p == nil {
1093		return 0
1094	}
1095	return seq
1096}
1097
1098func CreatePixmap(b *xturbo.Buf, depth uint8, pid Pixmap, drawable Drawable, width uint16, height uint16) xturbo.Seq {
1099	p, seq := b.Request(53, uint8(int(depth)), 12)
1100	if p == nil {
1101		return 0
1102	}
1103	binary.LittleEndian.PutUint32(p[0:], uint32(pid))
1104	binary.LittleEndian.PutUint32(p[4:], uint32(drawable))
1105	binary.LittleEndian.PutUint16(p[8:], uint16(width))
1106	binary.LittleEndian.PutUint16(p[10:], uint16(height))
1107	return seq
1108}
1109
1110func FreePixmap(b *xturbo.Buf, pixmap Pixmap) xturbo.Seq {
1111	p, seq := b.Request(54, 0, 4)
1112	if p == nil {
1113		return 0
1114	}
1115	binary.LittleEndian.PutUint32(p[0:], uint32(pixmap))
1116	return seq
1117}
1118
1119type CreateGCValues struct {
1120	Mask               Gc
1121	Function           Gx
1122	PlaneMask          uint32
1123	Foreground         uint32
1124	Background         uint32
1125	LineWidth          uint32
1126	LineStyle          LineStyle
1127	CapStyle           CapStyle
1128	JoinStyle          JoinStyle
1129	FillStyle          FillStyle
1130	FillRule           FillRule
1131	Tile               Pixmap
1132	Stipple            Pixmap
1133	TileStippleXOrigin int32
1134	TileStippleYOrigin int32
1135	Font               Font
1136	SubwindowMode      SubwindowMode
1137	GraphicsExposures  bool
1138	ClipXOrigin        int32
1139	ClipYOrigin        int32
1140	ClipMask           Pixmap
1141	DashOffset         uint32
1142	Dashes             uint32
1143	ArcMode            ArcMode
1144}
1145
1146func (v *CreateGCValues) SetFunction(x Gx) *CreateGCValues {
1147	v.Mask |= GcFunction
1148	v.Function = x
1149	return v
1150}
1151func (v *CreateGCValues) SetPlaneMask(x uint32) *CreateGCValues {
1152	v.Mask |= GcPlaneMask
1153	v.PlaneMask = x
1154	return v
1155}
1156func (v *CreateGCValues) SetForeground(x uint32) *CreateGCValues {
1157	v.Mask |= GcForeground
1158	v.Foreground = x
1159	return v
1160}
1161func (v *CreateGCValues) SetBackground(x uint32) *CreateGCValues {
1162	v.Mask |= GcBackground
1163	v.Background = x
1164	return v
1165}
1166func (v *CreateGCValues) SetLineWidth(x uint32) *CreateGCValues {
1167	v.Mask |= GcLineWidth
1168	v.LineWidth = x
1169	return v
1170}
1171func (v *CreateGCValues) SetLineStyle(x LineStyle) *CreateGCValues {
1172	v.Mask |= GcLineStyle
1173	v.LineStyle = x
1174	return v
1175}
1176func (v *CreateGCValues) SetCapStyle(x CapStyle) *CreateGCValues {
1177	v.Mask |= GcCapStyle
1178	v.CapStyle = x
1179	return v
1180}
1181func (v *CreateGCValues) SetJoinStyle(x JoinStyle) *CreateGCValues {
1182	v.Mask |= GcJoinStyle
1183	v.JoinStyle = x
1184	return v
1185}
1186func (v *CreateGCValues) SetFillStyle(x FillStyle) *CreateGCValues {
1187	v.Mask |= GcFillStyle
1188	v.FillStyle = x
1189	return v
1190}
1191func (v *CreateGCValues) SetFillRule(x FillRule) *CreateGCValues {
1192	v.Mask |= GcFillRule
1193	v.FillRule = x
1194	return v
1195}
1196func (v *CreateGCValues) SetTile(x Pixmap) *CreateGCValues { v.Mask |= GcTile; v.Tile = x; return v }
1197func (v *CreateGCValues) SetStipple(x Pixmap) *CreateGCValues {
1198	v.Mask |= GcStipple
1199	v.Stipple = x
1200	return v
1201}
1202func (v *CreateGCValues) SetTileStippleXOrigin(x int32) *CreateGCValues {
1203	v.Mask |= GcTileStippleOriginX
1204	v.TileStippleXOrigin = x
1205	return v
1206}
1207func (v *CreateGCValues) SetTileStippleYOrigin(x int32) *CreateGCValues {
1208	v.Mask |= GcTileStippleOriginY
1209	v.TileStippleYOrigin = x
1210	return v
1211}
1212func (v *CreateGCValues) SetFont(x Font) *CreateGCValues { v.Mask |= GcFont; v.Font = x; return v }
1213func (v *CreateGCValues) SetSubwindowMode(x SubwindowMode) *CreateGCValues {
1214	v.Mask |= GcSubwindowMode
1215	v.SubwindowMode = x
1216	return v
1217}
1218func (v *CreateGCValues) SetGraphicsExposures(x bool) *CreateGCValues {
1219	v.Mask |= GcGraphicsExposures
1220	v.GraphicsExposures = x
1221	return v
1222}
1223func (v *CreateGCValues) SetClipXOrigin(x int32) *CreateGCValues {
1224	v.Mask |= GcClipOriginX
1225	v.ClipXOrigin = x
1226	return v
1227}
1228func (v *CreateGCValues) SetClipYOrigin(x int32) *CreateGCValues {
1229	v.Mask |= GcClipOriginY
1230	v.ClipYOrigin = x
1231	return v
1232}
1233func (v *CreateGCValues) SetClipMask(x Pixmap) *CreateGCValues {
1234	v.Mask |= GcClipMask
1235	v.ClipMask = x
1236	return v
1237}
1238func (v *CreateGCValues) SetDashOffset(x uint32) *CreateGCValues {
1239	v.Mask |= GcDashOffset
1240	v.DashOffset = x
1241	return v
1242}
1243func (v *CreateGCValues) SetDashes(x uint32) *CreateGCValues {
1244	v.Mask |= GcDashList
1245	v.Dashes = x
1246	return v
1247}
1248func (v *CreateGCValues) SetArcMode(x ArcMode) *CreateGCValues {
1249	v.Mask |= GcArcMode
1250	v.ArcMode = x
1251	return v
1252}
1253func CreateGC(b *xturbo.Buf, cid Gcontext, drawable Drawable, v *CreateGCValues) xturbo.Seq {
1254	p, seq := b.Request(55, 0, 12+4*bits.OnesCount32(uint32(v.Mask)))
1255	if p == nil {
1256		return 0
1257	}
1258	binary.LittleEndian.PutUint32(p[0:], uint32(cid))
1259	binary.LittleEndian.PutUint32(p[4:], uint32(drawable))
1260	binary.LittleEndian.PutUint32(p[8:], uint32(v.Mask))
1261	off := 12
1262	if v.Mask&GcFunction != 0 {
1263		binary.LittleEndian.PutUint32(p[off:], uint32(v.Function))
1264		off += 4
1265	}
1266	if v.Mask&GcPlaneMask != 0 {
1267		binary.LittleEndian.PutUint32(p[off:], uint32(v.PlaneMask))
1268		off += 4
1269	}
1270	if v.Mask&GcForeground != 0 {
1271		binary.LittleEndian.PutUint32(p[off:], uint32(v.Foreground))
1272		off += 4
1273	}
1274	if v.Mask&GcBackground != 0 {
1275		binary.LittleEndian.PutUint32(p[off:], uint32(v.Background))
1276		off += 4
1277	}
1278	if v.Mask&GcLineWidth != 0 {
1279		binary.LittleEndian.PutUint32(p[off:], uint32(v.LineWidth))
1280		off += 4
1281	}
1282	if v.Mask&GcLineStyle != 0 {
1283		binary.LittleEndian.PutUint32(p[off:], uint32(v.LineStyle))
1284		off += 4
1285	}
1286	if v.Mask&GcCapStyle != 0 {
1287		binary.LittleEndian.PutUint32(p[off:], uint32(v.CapStyle))
1288		off += 4
1289	}
1290	if v.Mask&GcJoinStyle != 0 {
1291		binary.LittleEndian.PutUint32(p[off:], uint32(v.JoinStyle))
1292		off += 4
1293	}
1294	if v.Mask&GcFillStyle != 0 {
1295		binary.LittleEndian.PutUint32(p[off:], uint32(v.FillStyle))
1296		off += 4
1297	}
1298	if v.Mask&GcFillRule != 0 {
1299		binary.LittleEndian.PutUint32(p[off:], uint32(v.FillRule))
1300		off += 4
1301	}
1302	if v.Mask&GcTile != 0 {
1303		binary.LittleEndian.PutUint32(p[off:], uint32(v.Tile))
1304		off += 4
1305	}
1306	if v.Mask&GcStipple != 0 {
1307		binary.LittleEndian.PutUint32(p[off:], uint32(v.Stipple))
1308		off += 4
1309	}
1310	if v.Mask&GcTileStippleOriginX != 0 {
1311		binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleXOrigin))
1312		off += 4
1313	}
1314	if v.Mask&GcTileStippleOriginY != 0 {
1315		binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleYOrigin))
1316		off += 4
1317	}
1318	if v.Mask&GcFont != 0 {
1319		binary.LittleEndian.PutUint32(p[off:], uint32(v.Font))
1320		off += 4
1321	}
1322	if v.Mask&GcSubwindowMode != 0 {
1323		binary.LittleEndian.PutUint32(p[off:], uint32(v.SubwindowMode))
1324		off += 4
1325	}
1326	if v.Mask&GcGraphicsExposures != 0 {
1327		if v.GraphicsExposures {
1328			binary.LittleEndian.PutUint32(p[off:], 1)
1329		} else {
1330			binary.LittleEndian.PutUint32(p[off:], 0)
1331		}
1332		off += 4
1333	}
1334	if v.Mask&GcClipOriginX != 0 {
1335		binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipXOrigin))
1336		off += 4
1337	}
1338	if v.Mask&GcClipOriginY != 0 {
1339		binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipYOrigin))
1340		off += 4
1341	}
1342	if v.Mask&GcClipMask != 0 {
1343		binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipMask))
1344		off += 4
1345	}
1346	if v.Mask&GcDashOffset != 0 {
1347		binary.LittleEndian.PutUint32(p[off:], uint32(v.DashOffset))
1348		off += 4
1349	}
1350	if v.Mask&GcDashList != 0 {
1351		binary.LittleEndian.PutUint32(p[off:], uint32(v.Dashes))
1352		off += 4
1353	}
1354	if v.Mask&GcArcMode != 0 {
1355		binary.LittleEndian.PutUint32(p[off:], uint32(v.ArcMode))
1356		off += 4
1357	}
1358	_ = off
1359	return seq
1360}
1361
1362type ChangeGCValues struct {
1363	Mask               Gc
1364	Function           Gx
1365	PlaneMask          uint32
1366	Foreground         uint32
1367	Background         uint32
1368	LineWidth          uint32
1369	LineStyle          LineStyle
1370	CapStyle           CapStyle
1371	JoinStyle          JoinStyle
1372	FillStyle          FillStyle
1373	FillRule           FillRule
1374	Tile               Pixmap
1375	Stipple            Pixmap
1376	TileStippleXOrigin int32
1377	TileStippleYOrigin int32
1378	Font               Font
1379	SubwindowMode      SubwindowMode
1380	GraphicsExposures  bool
1381	ClipXOrigin        int32
1382	ClipYOrigin        int32
1383	ClipMask           Pixmap
1384	DashOffset         uint32
1385	Dashes             uint32
1386	ArcMode            ArcMode
1387}
1388
1389func (v *ChangeGCValues) SetFunction(x Gx) *ChangeGCValues {
1390	v.Mask |= GcFunction
1391	v.Function = x
1392	return v
1393}
1394func (v *ChangeGCValues) SetPlaneMask(x uint32) *ChangeGCValues {
1395	v.Mask |= GcPlaneMask
1396	v.PlaneMask = x
1397	return v
1398}
1399func (v *ChangeGCValues) SetForeground(x uint32) *ChangeGCValues {
1400	v.Mask |= GcForeground
1401	v.Foreground = x
1402	return v
1403}
1404func (v *ChangeGCValues) SetBackground(x uint32) *ChangeGCValues {
1405	v.Mask |= GcBackground
1406	v.Background = x
1407	return v
1408}
1409func (v *ChangeGCValues) SetLineWidth(x uint32) *ChangeGCValues {
1410	v.Mask |= GcLineWidth
1411	v.LineWidth = x
1412	return v
1413}
1414func (v *ChangeGCValues) SetLineStyle(x LineStyle) *ChangeGCValues {
1415	v.Mask |= GcLineStyle
1416	v.LineStyle = x
1417	return v
1418}
1419func (v *ChangeGCValues) SetCapStyle(x CapStyle) *ChangeGCValues {
1420	v.Mask |= GcCapStyle
1421	v.CapStyle = x
1422	return v
1423}
1424func (v *ChangeGCValues) SetJoinStyle(x JoinStyle) *ChangeGCValues {
1425	v.Mask |= GcJoinStyle
1426	v.JoinStyle = x
1427	return v
1428}
1429func (v *ChangeGCValues) SetFillStyle(x FillStyle) *ChangeGCValues {
1430	v.Mask |= GcFillStyle
1431	v.FillStyle = x
1432	return v
1433}
1434func (v *ChangeGCValues) SetFillRule(x FillRule) *ChangeGCValues {
1435	v.Mask |= GcFillRule
1436	v.FillRule = x
1437	return v
1438}
1439func (v *ChangeGCValues) SetTile(x Pixmap) *ChangeGCValues { v.Mask |= GcTile; v.Tile = x; return v }
1440func (v *ChangeGCValues) SetStipple(x Pixmap) *ChangeGCValues {
1441	v.Mask |= GcStipple
1442	v.Stipple = x
1443	return v
1444}
1445func (v *ChangeGCValues) SetTileStippleXOrigin(x int32) *ChangeGCValues {
1446	v.Mask |= GcTileStippleOriginX
1447	v.TileStippleXOrigin = x
1448	return v
1449}
1450func (v *ChangeGCValues) SetTileStippleYOrigin(x int32) *ChangeGCValues {
1451	v.Mask |= GcTileStippleOriginY
1452	v.TileStippleYOrigin = x
1453	return v
1454}
1455func (v *ChangeGCValues) SetFont(x Font) *ChangeGCValues { v.Mask |= GcFont; v.Font = x; return v }
1456func (v *ChangeGCValues) SetSubwindowMode(x SubwindowMode) *ChangeGCValues {
1457	v.Mask |= GcSubwindowMode
1458	v.SubwindowMode = x
1459	return v
1460}
1461func (v *ChangeGCValues) SetGraphicsExposures(x bool) *ChangeGCValues {
1462	v.Mask |= GcGraphicsExposures
1463	v.GraphicsExposures = x
1464	return v
1465}
1466func (v *ChangeGCValues) SetClipXOrigin(x int32) *ChangeGCValues {
1467	v.Mask |= GcClipOriginX
1468	v.ClipXOrigin = x
1469	return v
1470}
1471func (v *ChangeGCValues) SetClipYOrigin(x int32) *ChangeGCValues {
1472	v.Mask |= GcClipOriginY
1473	v.ClipYOrigin = x
1474	return v
1475}
1476func (v *ChangeGCValues) SetClipMask(x Pixmap) *ChangeGCValues {
1477	v.Mask |= GcClipMask
1478	v.ClipMask = x
1479	return v
1480}
1481func (v *ChangeGCValues) SetDashOffset(x uint32) *ChangeGCValues {
1482	v.Mask |= GcDashOffset
1483	v.DashOffset = x
1484	return v
1485}
1486func (v *ChangeGCValues) SetDashes(x uint32) *ChangeGCValues {
1487	v.Mask |= GcDashList
1488	v.Dashes = x
1489	return v
1490}
1491func (v *ChangeGCValues) SetArcMode(x ArcMode) *ChangeGCValues {
1492	v.Mask |= GcArcMode
1493	v.ArcMode = x
1494	return v
1495}
1496func ChangeGC(b *xturbo.Buf, gc Gcontext, v *ChangeGCValues) xturbo.Seq {
1497	p, seq := b.Request(56, 0, 8+4*bits.OnesCount32(uint32(v.Mask)))
1498	if p == nil {
1499		return 0
1500	}
1501	binary.LittleEndian.PutUint32(p[0:], uint32(gc))
1502	binary.LittleEndian.PutUint32(p[4:], uint32(v.Mask))
1503	off := 8
1504	if v.Mask&GcFunction != 0 {
1505		binary.LittleEndian.PutUint32(p[off:], uint32(v.Function))
1506		off += 4
1507	}
1508	if v.Mask&GcPlaneMask != 0 {
1509		binary.LittleEndian.PutUint32(p[off:], uint32(v.PlaneMask))
1510		off += 4
1511	}
1512	if v.Mask&GcForeground != 0 {
1513		binary.LittleEndian.PutUint32(p[off:], uint32(v.Foreground))
1514		off += 4
1515	}
1516	if v.Mask&GcBackground != 0 {
1517		binary.LittleEndian.PutUint32(p[off:], uint32(v.Background))
1518		off += 4
1519	}
1520	if v.Mask&GcLineWidth != 0 {
1521		binary.LittleEndian.PutUint32(p[off:], uint32(v.LineWidth))
1522		off += 4
1523	}
1524	if v.Mask&GcLineStyle != 0 {
1525		binary.LittleEndian.PutUint32(p[off:], uint32(v.LineStyle))
1526		off += 4
1527	}
1528	if v.Mask&GcCapStyle != 0 {
1529		binary.LittleEndian.PutUint32(p[off:], uint32(v.CapStyle))
1530		off += 4
1531	}
1532	if v.Mask&GcJoinStyle != 0 {
1533		binary.LittleEndian.PutUint32(p[off:], uint32(v.JoinStyle))
1534		off += 4
1535	}
1536	if v.Mask&GcFillStyle != 0 {
1537		binary.LittleEndian.PutUint32(p[off:], uint32(v.FillStyle))
1538		off += 4
1539	}
1540	if v.Mask&GcFillRule != 0 {
1541		binary.LittleEndian.PutUint32(p[off:], uint32(v.FillRule))
1542		off += 4
1543	}
1544	if v.Mask&GcTile != 0 {
1545		binary.LittleEndian.PutUint32(p[off:], uint32(v.Tile))
1546		off += 4
1547	}
1548	if v.Mask&GcStipple != 0 {
1549		binary.LittleEndian.PutUint32(p[off:], uint32(v.Stipple))
1550		off += 4
1551	}
1552	if v.Mask&GcTileStippleOriginX != 0 {
1553		binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleXOrigin))
1554		off += 4
1555	}
1556	if v.Mask&GcTileStippleOriginY != 0 {
1557		binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleYOrigin))
1558		off += 4
1559	}
1560	if v.Mask&GcFont != 0 {
1561		binary.LittleEndian.PutUint32(p[off:], uint32(v.Font))
1562		off += 4
1563	}
1564	if v.Mask&GcSubwindowMode != 0 {
1565		binary.LittleEndian.PutUint32(p[off:], uint32(v.SubwindowMode))
1566		off += 4
1567	}
1568	if v.Mask&GcGraphicsExposures != 0 {
1569		if v.GraphicsExposures {
1570			binary.LittleEndian.PutUint32(p[off:], 1)
1571		} else {
1572			binary.LittleEndian.PutUint32(p[off:], 0)
1573		}
1574		off += 4
1575	}
1576	if v.Mask&GcClipOriginX != 0 {
1577		binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipXOrigin))
1578		off += 4
1579	}
1580	if v.Mask&GcClipOriginY != 0 {
1581		binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipYOrigin))
1582		off += 4
1583	}
1584	if v.Mask&GcClipMask != 0 {
1585		binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipMask))
1586		off += 4
1587	}
1588	if v.Mask&GcDashOffset != 0 {
1589		binary.LittleEndian.PutUint32(p[off:], uint32(v.DashOffset))
1590		off += 4
1591	}
1592	if v.Mask&GcDashList != 0 {
1593		binary.LittleEndian.PutUint32(p[off:], uint32(v.Dashes))
1594		off += 4
1595	}
1596	if v.Mask&GcArcMode != 0 {
1597		binary.LittleEndian.PutUint32(p[off:], uint32(v.ArcMode))
1598		off += 4
1599	}
1600	_ = off
1601	return seq
1602}
1603
1604func CopyGC(b *xturbo.Buf, srcGc Gcontext, dstGc Gcontext, valueMask Gc) xturbo.Seq {
1605	p, seq := b.Request(57, 0, 12)
1606	if p == nil {
1607		return 0
1608	}
1609	binary.LittleEndian.PutUint32(p[0:], uint32(srcGc))
1610	binary.LittleEndian.PutUint32(p[4:], uint32(dstGc))
1611	binary.LittleEndian.PutUint32(p[8:], uint32(valueMask))
1612	return seq
1613}
1614
1615func SetDashes(b *xturbo.Buf, gc Gcontext, dashOffset uint16, dashes []byte) xturbo.Seq {
1616	if uint64(len(dashes)) > 65535 {
1617		b.Fail(xturbo.ErrBadLength)
1618		return 0
1619	}
1620	size := 0
1621	size += 4
1622	size += 2
1623	size += 2
1624	size += len(dashes) * 1
1625	size = (size + 3) &^ 3
1626	p, seq := b.Request(58, 0, size)
1627	if p == nil {
1628		return 0
1629	}
1630	off := 0
1631	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1632	off += 4
1633	binary.LittleEndian.PutUint16(p[off:], uint16(dashOffset))
1634	off += 2
1635	binary.LittleEndian.PutUint16(p[off:], uint16(len(dashes)))
1636	off += 2
1637	copy(p[off:], dashes)
1638	off += len(dashes)
1639	return seq
1640}
1641
1642func SetClipRectangles(b *xturbo.Buf, ordering ClipOrdering, gc Gcontext, clipXOrigin int16, clipYOrigin int16, rectangles []Rectangle) xturbo.Seq {
1643	size := 0
1644	size += 4
1645	size += 2
1646	size += 2
1647	size += len(rectangles) * 8
1648	size = (size + 3) &^ 3
1649	p, seq := b.Request(59, uint8(int(ordering)), size)
1650	if p == nil {
1651		return 0
1652	}
1653	off := 0
1654	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1655	off += 4
1656	binary.LittleEndian.PutUint16(p[off:], uint16(clipXOrigin))
1657	off += 2
1658	binary.LittleEndian.PutUint16(p[off:], uint16(clipYOrigin))
1659	off += 2
1660	for i := range rectangles {
1661		rectangles[i].Put(p[off:])
1662		off += 8
1663	}
1664	return seq
1665}
1666
1667func FreeGC(b *xturbo.Buf, gc Gcontext) xturbo.Seq {
1668	p, seq := b.Request(60, 0, 4)
1669	if p == nil {
1670		return 0
1671	}
1672	binary.LittleEndian.PutUint32(p[0:], uint32(gc))
1673	return seq
1674}
1675
1676func ClearArea(b *xturbo.Buf, exposures bool, window Window, x int16, y int16, width uint16, height uint16) xturbo.Seq {
1677	var data uint8
1678	if exposures {
1679		data = 1
1680	}
1681	p, seq := b.Request(61, data, 12)
1682	if p == nil {
1683		return 0
1684	}
1685	binary.LittleEndian.PutUint32(p[0:], uint32(window))
1686	binary.LittleEndian.PutUint16(p[4:], uint16(x))
1687	binary.LittleEndian.PutUint16(p[6:], uint16(y))
1688	binary.LittleEndian.PutUint16(p[8:], uint16(width))
1689	binary.LittleEndian.PutUint16(p[10:], uint16(height))
1690	return seq
1691}
1692
1693func CopyArea(b *xturbo.Buf, srcDrawable Drawable, dstDrawable Drawable, gc Gcontext, srcX int16, srcY int16, dstX int16, dstY int16, width uint16, height uint16) xturbo.Seq {
1694	p, seq := b.Request(62, 0, 24)
1695	if p == nil {
1696		return 0
1697	}
1698	binary.LittleEndian.PutUint32(p[0:], uint32(srcDrawable))
1699	binary.LittleEndian.PutUint32(p[4:], uint32(dstDrawable))
1700	binary.LittleEndian.PutUint32(p[8:], uint32(gc))
1701	binary.LittleEndian.PutUint16(p[12:], uint16(srcX))
1702	binary.LittleEndian.PutUint16(p[14:], uint16(srcY))
1703	binary.LittleEndian.PutUint16(p[16:], uint16(dstX))
1704	binary.LittleEndian.PutUint16(p[18:], uint16(dstY))
1705	binary.LittleEndian.PutUint16(p[20:], uint16(width))
1706	binary.LittleEndian.PutUint16(p[22:], uint16(height))
1707	return seq
1708}
1709
1710func CopyPlane(b *xturbo.Buf, srcDrawable Drawable, dstDrawable Drawable, gc Gcontext, srcX int16, srcY int16, dstX int16, dstY int16, width uint16, height uint16, bitPlane uint32) xturbo.Seq {
1711	p, seq := b.Request(63, 0, 28)
1712	if p == nil {
1713		return 0
1714	}
1715	binary.LittleEndian.PutUint32(p[0:], uint32(srcDrawable))
1716	binary.LittleEndian.PutUint32(p[4:], uint32(dstDrawable))
1717	binary.LittleEndian.PutUint32(p[8:], uint32(gc))
1718	binary.LittleEndian.PutUint16(p[12:], uint16(srcX))
1719	binary.LittleEndian.PutUint16(p[14:], uint16(srcY))
1720	binary.LittleEndian.PutUint16(p[16:], uint16(dstX))
1721	binary.LittleEndian.PutUint16(p[18:], uint16(dstY))
1722	binary.LittleEndian.PutUint16(p[20:], uint16(width))
1723	binary.LittleEndian.PutUint16(p[22:], uint16(height))
1724	binary.LittleEndian.PutUint32(p[24:], uint32(bitPlane))
1725	return seq
1726}
1727
1728func PolyPoint(b *xturbo.Buf, coordinateMode CoordMode, drawable Drawable, gc Gcontext, points []Point) xturbo.Seq {
1729	size := 0
1730	size += 4
1731	size += 4
1732	size += len(points) * 4
1733	size = (size + 3) &^ 3
1734	p, seq := b.Request(64, uint8(int(coordinateMode)), size)
1735	if p == nil {
1736		return 0
1737	}
1738	off := 0
1739	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1740	off += 4
1741	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1742	off += 4
1743	for i := range points {
1744		points[i].Put(p[off:])
1745		off += 4
1746	}
1747	return seq
1748}
1749
1750func PolyLine(b *xturbo.Buf, coordinateMode CoordMode, drawable Drawable, gc Gcontext, points []Point) xturbo.Seq {
1751	size := 0
1752	size += 4
1753	size += 4
1754	size += len(points) * 4
1755	size = (size + 3) &^ 3
1756	p, seq := b.Request(65, uint8(int(coordinateMode)), size)
1757	if p == nil {
1758		return 0
1759	}
1760	off := 0
1761	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1762	off += 4
1763	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1764	off += 4
1765	for i := range points {
1766		points[i].Put(p[off:])
1767		off += 4
1768	}
1769	return seq
1770}
1771
1772func PolySegment(b *xturbo.Buf, drawable Drawable, gc Gcontext, segments []Segment) xturbo.Seq {
1773	size := 0
1774	size += 4
1775	size += 4
1776	size += len(segments) * 8
1777	size = (size + 3) &^ 3
1778	p, seq := b.Request(66, 0, size)
1779	if p == nil {
1780		return 0
1781	}
1782	off := 0
1783	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1784	off += 4
1785	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1786	off += 4
1787	for i := range segments {
1788		segments[i].Put(p[off:])
1789		off += 8
1790	}
1791	return seq
1792}
1793
1794func PolyRectangle(b *xturbo.Buf, drawable Drawable, gc Gcontext, rectangles []Rectangle) xturbo.Seq {
1795	size := 0
1796	size += 4
1797	size += 4
1798	size += len(rectangles) * 8
1799	size = (size + 3) &^ 3
1800	p, seq := b.Request(67, 0, size)
1801	if p == nil {
1802		return 0
1803	}
1804	off := 0
1805	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1806	off += 4
1807	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1808	off += 4
1809	for i := range rectangles {
1810		rectangles[i].Put(p[off:])
1811		off += 8
1812	}
1813	return seq
1814}
1815
1816func PolyArc(b *xturbo.Buf, drawable Drawable, gc Gcontext, arcs []Arc) xturbo.Seq {
1817	size := 0
1818	size += 4
1819	size += 4
1820	size += len(arcs) * 12
1821	size = (size + 3) &^ 3
1822	p, seq := b.Request(68, 0, size)
1823	if p == nil {
1824		return 0
1825	}
1826	off := 0
1827	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1828	off += 4
1829	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1830	off += 4
1831	for i := range arcs {
1832		arcs[i].Put(p[off:])
1833		off += 12
1834	}
1835	return seq
1836}
1837
1838func FillPoly(b *xturbo.Buf, drawable Drawable, gc Gcontext, shape PolyShape, coordinateMode CoordMode, points []Point) xturbo.Seq {
1839	size := 0
1840	size += 4
1841	size += 4
1842	size += 1
1843	size += 1
1844	size += 2
1845	size += len(points) * 4
1846	size = (size + 3) &^ 3
1847	p, seq := b.Request(69, 0, size)
1848	if p == nil {
1849		return 0
1850	}
1851	off := 0
1852	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1853	off += 4
1854	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1855	off += 4
1856	p[off:][0] = byte(shape)
1857	off += 1
1858	p[off:][0] = byte(coordinateMode)
1859	off += 1
1860	off += 2
1861	for i := range points {
1862		points[i].Put(p[off:])
1863		off += 4
1864	}
1865	return seq
1866}
1867
1868func PolyFillRectangle(b *xturbo.Buf, drawable Drawable, gc Gcontext, rectangles []Rectangle) xturbo.Seq {
1869	size := 0
1870	size += 4
1871	size += 4
1872	size += len(rectangles) * 8
1873	size = (size + 3) &^ 3
1874	p, seq := b.Request(70, 0, size)
1875	if p == nil {
1876		return 0
1877	}
1878	off := 0
1879	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1880	off += 4
1881	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1882	off += 4
1883	for i := range rectangles {
1884		rectangles[i].Put(p[off:])
1885		off += 8
1886	}
1887	return seq
1888}
1889
1890func PolyFillArc(b *xturbo.Buf, drawable Drawable, gc Gcontext, arcs []Arc) xturbo.Seq {
1891	size := 0
1892	size += 4
1893	size += 4
1894	size += len(arcs) * 12
1895	size = (size + 3) &^ 3
1896	p, seq := b.Request(71, 0, size)
1897	if p == nil {
1898		return 0
1899	}
1900	off := 0
1901	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1902	off += 4
1903	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1904	off += 4
1905	for i := range arcs {
1906		arcs[i].Put(p[off:])
1907		off += 12
1908	}
1909	return seq
1910}
1911
1912func PutImage(b *xturbo.Buf, format ImageFormat, drawable Drawable, gc Gcontext, width uint16, height uint16, dstX int16, dstY int16, leftPad uint8, depth uint8, data []byte) xturbo.Seq {
1913	size := 0
1914	size += 4
1915	size += 4
1916	size += 2
1917	size += 2
1918	size += 2
1919	size += 2
1920	size += 1
1921	size += 1
1922	size += 2
1923	size += len(data) * 1
1924	size = (size + 3) &^ 3
1925	p, seq := b.Request(72, uint8(int(format)), size)
1926	if p == nil {
1927		return 0
1928	}
1929	off := 0
1930	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1931	off += 4
1932	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1933	off += 4
1934	binary.LittleEndian.PutUint16(p[off:], uint16(width))
1935	off += 2
1936	binary.LittleEndian.PutUint16(p[off:], uint16(height))
1937	off += 2
1938	binary.LittleEndian.PutUint16(p[off:], uint16(dstX))
1939	off += 2
1940	binary.LittleEndian.PutUint16(p[off:], uint16(dstY))
1941	off += 2
1942	p[off:][0] = byte(leftPad)
1943	off += 1
1944	p[off:][0] = byte(depth)
1945	off += 1
1946	off += 2
1947	copy(p[off:], data)
1948	off += len(data)
1949	return seq
1950}
1951
1952func GetImage(b *xturbo.Buf, format ImageFormat, drawable Drawable, x int16, y int16, width uint16, height uint16, planeMask uint32) xturbo.Seq {
1953	p, seq := b.Request(73, uint8(int(format)), 16)
1954	if p == nil {
1955		return 0
1956	}
1957	binary.LittleEndian.PutUint32(p[0:], uint32(drawable))
1958	binary.LittleEndian.PutUint16(p[4:], uint16(x))
1959	binary.LittleEndian.PutUint16(p[6:], uint16(y))
1960	binary.LittleEndian.PutUint16(p[8:], uint16(width))
1961	binary.LittleEndian.PutUint16(p[10:], uint16(height))
1962	binary.LittleEndian.PutUint32(p[12:], uint32(planeMask))
1963	return seq
1964}
1965
1966func PolyText8(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, items []byte) xturbo.Seq {
1967	size := 0
1968	size += 4
1969	size += 4
1970	size += 2
1971	size += 2
1972	size += len(items) * 1
1973	size = (size + 3) &^ 3
1974	p, seq := b.Request(74, 0, size)
1975	if p == nil {
1976		return 0
1977	}
1978	off := 0
1979	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
1980	off += 4
1981	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
1982	off += 4
1983	binary.LittleEndian.PutUint16(p[off:], uint16(x))
1984	off += 2
1985	binary.LittleEndian.PutUint16(p[off:], uint16(y))
1986	off += 2
1987	copy(p[off:], items)
1988	off += len(items)
1989	return seq
1990}
1991
1992func PolyText16(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, items []byte) xturbo.Seq {
1993	size := 0
1994	size += 4
1995	size += 4
1996	size += 2
1997	size += 2
1998	size += len(items) * 1
1999	size = (size + 3) &^ 3
2000	p, seq := b.Request(75, 0, size)
2001	if p == nil {
2002		return 0
2003	}
2004	off := 0
2005	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
2006	off += 4
2007	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
2008	off += 4
2009	binary.LittleEndian.PutUint16(p[off:], uint16(x))
2010	off += 2
2011	binary.LittleEndian.PutUint16(p[off:], uint16(y))
2012	off += 2
2013	copy(p[off:], items)
2014	off += len(items)
2015	return seq
2016}
2017
2018func ImageText8(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, string string) xturbo.Seq {
2019	if len(string) > 255 {
2020		b.Fail(xturbo.ErrBadLength)
2021		return 0
2022	}
2023	size := 0
2024	size += 4
2025	size += 4
2026	size += 2
2027	size += 2
2028	size += len(string) * 1
2029	size = (size + 3) &^ 3
2030	p, seq := b.Request(76, uint8(len(string)), size)
2031	if p == nil {
2032		return 0
2033	}
2034	off := 0
2035	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
2036	off += 4
2037	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
2038	off += 4
2039	binary.LittleEndian.PutUint16(p[off:], uint16(x))
2040	off += 2
2041	binary.LittleEndian.PutUint16(p[off:], uint16(y))
2042	off += 2
2043	copy(p[off:], string)
2044	off += len(string)
2045	return seq
2046}
2047
2048func ImageText16(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, string []Char2b) xturbo.Seq {
2049	if len(string) > 255 {
2050		b.Fail(xturbo.ErrBadLength)
2051		return 0
2052	}
2053	size := 0
2054	size += 4
2055	size += 4
2056	size += 2
2057	size += 2
2058	size += len(string) * 2
2059	size = (size + 3) &^ 3
2060	p, seq := b.Request(77, uint8(len(string)), size)
2061	if p == nil {
2062		return 0
2063	}
2064	off := 0
2065	binary.LittleEndian.PutUint32(p[off:], uint32(drawable))
2066	off += 4
2067	binary.LittleEndian.PutUint32(p[off:], uint32(gc))
2068	off += 4
2069	binary.LittleEndian.PutUint16(p[off:], uint16(x))
2070	off += 2
2071	binary.LittleEndian.PutUint16(p[off:], uint16(y))
2072	off += 2
2073	for i := range string {
2074		string[i].Put(p[off:])
2075		off += 2
2076	}
2077	return seq
2078}
2079
2080func CreateColormap(b *xturbo.Buf, alloc ColormapAlloc, mid Colormap, window Window, visual Visualid) xturbo.Seq {
2081	p, seq := b.Request(78, uint8(int(alloc)), 12)
2082	if p == nil {
2083		return 0
2084	}
2085	binary.LittleEndian.PutUint32(p[0:], uint32(mid))
2086	binary.LittleEndian.PutUint32(p[4:], uint32(window))
2087	binary.LittleEndian.PutUint32(p[8:], uint32(visual))
2088	return seq
2089}
2090
2091func FreeColormap(b *xturbo.Buf, cmap Colormap) xturbo.Seq {
2092	p, seq := b.Request(79, 0, 4)
2093	if p == nil {
2094		return 0
2095	}
2096	binary.LittleEndian.PutUint32(p[0:], uint32(cmap))
2097	return seq
2098}
2099
2100func CopyColormapAndFree(b *xturbo.Buf, mid Colormap, srcCmap Colormap) xturbo.Seq {
2101	p, seq := b.Request(80, 0, 8)
2102	if p == nil {
2103		return 0
2104	}
2105	binary.LittleEndian.PutUint32(p[0:], uint32(mid))
2106	binary.LittleEndian.PutUint32(p[4:], uint32(srcCmap))
2107	return seq
2108}
2109
2110func InstallColormap(b *xturbo.Buf, cmap Colormap) xturbo.Seq {
2111	p, seq := b.Request(81, 0, 4)
2112	if p == nil {
2113		return 0
2114	}
2115	binary.LittleEndian.PutUint32(p[0:], uint32(cmap))
2116	return seq
2117}
2118
2119func UninstallColormap(b *xturbo.Buf, cmap Colormap) xturbo.Seq {
2120	p, seq := b.Request(82, 0, 4)
2121	if p == nil {
2122		return 0
2123	}
2124	binary.LittleEndian.PutUint32(p[0:], uint32(cmap))
2125	return seq
2126}
2127
2128func ListInstalledColormaps(b *xturbo.Buf, window Window) xturbo.Seq {
2129	p, seq := b.Request(83, 0, 4)
2130	if p == nil {
2131		return 0
2132	}
2133	binary.LittleEndian.PutUint32(p[0:], uint32(window))
2134	return seq
2135}
2136
2137func AllocColor(b *xturbo.Buf, cmap Colormap, red uint16, green uint16, blue uint16) xturbo.Seq {
2138	p, seq := b.Request(84, 0, 12)
2139	if p == nil {
2140		return 0
2141	}
2142	binary.LittleEndian.PutUint32(p[0:], uint32(cmap))
2143	binary.LittleEndian.PutUint16(p[4:], uint16(red))
2144	binary.LittleEndian.PutUint16(p[6:], uint16(green))
2145	binary.LittleEndian.PutUint16(p[8:], uint16(blue))
2146	return seq
2147}
2148
2149func AllocNamedColor(b *xturbo.Buf, cmap Colormap, name string) xturbo.Seq {
2150	if uint64(len(name)) > 65535 {
2151		b.Fail(xturbo.ErrBadLength)
2152		return 0
2153	}
2154	size := 0
2155	size += 4
2156	size += 2
2157	size += 2
2158	size += len(name) * 1
2159	size = (size + 3) &^ 3
2160	p, seq := b.Request(85, 0, size)
2161	if p == nil {
2162		return 0
2163	}
2164	off := 0
2165	binary.LittleEndian.PutUint32(p[off:], uint32(cmap))
2166	off += 4
2167	binary.LittleEndian.PutUint16(p[off:], uint16(len(name)))
2168	off += 2
2169	off += 2
2170	copy(p[off:], name)
2171	off += len(name)
2172	return seq
2173}
2174
2175func AllocColorCells(b *xturbo.Buf, contiguous bool, cmap Colormap, colors uint16, planes uint16) xturbo.Seq {
2176	var data uint8
2177	if contiguous {
2178		data = 1
2179	}
2180	p, seq := b.Request(86, data, 8)
2181	if p == nil {
2182		return 0
2183	}
2184	binary.LittleEndian.PutUint32(p[0:], uint32(cmap))
2185	binary.LittleEndian.PutUint16(p[4:], uint16(colors))
2186	binary.LittleEndian.PutUint16(p[6:], uint16(planes))
2187	return seq
2188}
2189
2190func AllocColorPlanes(b *xturbo.Buf, contiguous bool, cmap Colormap, colors uint16, reds uint16, greens uint16, blues uint16) xturbo.Seq {
2191	var data uint8
2192	if contiguous {
2193		data = 1
2194	}
2195	p, seq := b.Request(87, data, 12)
2196	if p == nil {
2197		return 0
2198	}
2199	binary.LittleEndian.PutUint32(p[0:], uint32(cmap))
2200	binary.LittleEndian.PutUint16(p[4:], uint16(colors))
2201	binary.LittleEndian.PutUint16(p[6:], uint16(reds))
2202	binary.LittleEndian.PutUint16(p[8:], uint16(greens))
2203	binary.LittleEndian.PutUint16(p[10:], uint16(blues))
2204	return seq
2205}
2206
2207func FreeColors(b *xturbo.Buf, cmap Colormap, planeMask uint32, pixels []uint32) xturbo.Seq {
2208	size := 0
2209	size += 4
2210	size += 4
2211	size += len(pixels) * 4
2212	size = (size + 3) &^ 3
2213	p, seq := b.Request(88, 0, size)
2214	if p == nil {
2215		return 0
2216	}
2217	off := 0
2218	binary.LittleEndian.PutUint32(p[off:], uint32(cmap))
2219	off += 4
2220	binary.LittleEndian.PutUint32(p[off:], uint32(planeMask))
2221	off += 4
2222	for i := range pixels {
2223		binary.LittleEndian.PutUint32(p[off:], uint32(pixels[i]))
2224		off += 4
2225	}
2226	return seq
2227}
2228
2229func StoreColors(b *xturbo.Buf, cmap Colormap, items []Coloritem) xturbo.Seq {
2230	size := 0
2231	size += 4
2232	size += len(items) * 12
2233	size = (size + 3) &^ 3
2234	p, seq := b.Request(89, 0, size)
2235	if p == nil {
2236		return 0
2237	}
2238	off := 0
2239	binary.LittleEndian.PutUint32(p[off:], uint32(cmap))
2240	off += 4
2241	for i := range items {
2242		items[i].Put(p[off:])
2243		off += 12
2244	}
2245	return seq
2246}
2247
2248func StoreNamedColor(b *xturbo.Buf, flags ColorFlag, cmap Colormap, pixel uint32, name string) xturbo.Seq {
2249	if uint64(len(name)) > 65535 {
2250		b.Fail(xturbo.ErrBadLength)
2251		return 0
2252	}
2253	size := 0
2254	size += 4
2255	size += 4
2256	size += 2
2257	size += 2
2258	size += len(name) * 1
2259	size = (size + 3) &^ 3
2260	p, seq := b.Request(90, uint8(int(flags)), size)
2261	if p == nil {
2262		return 0
2263	}
2264	off := 0
2265	binary.LittleEndian.PutUint32(p[off:], uint32(cmap))
2266	off += 4
2267	binary.LittleEndian.PutUint32(p[off:], uint32(pixel))
2268	off += 4
2269	binary.LittleEndian.PutUint16(p[off:], uint16(len(name)))
2270	off += 2
2271	off += 2
2272	copy(p[off:], name)
2273	off += len(name)
2274	return seq
2275}
2276
2277func QueryColors(b *xturbo.Buf, cmap Colormap, pixels []uint32) xturbo.Seq {
2278	size := 0
2279	size += 4
2280	size += len(pixels) * 4
2281	size = (size + 3) &^ 3
2282	p, seq := b.Request(91, 0, size)
2283	if p == nil {
2284		return 0
2285	}
2286	off := 0
2287	binary.LittleEndian.PutUint32(p[off:], uint32(cmap))
2288	off += 4
2289	for i := range pixels {
2290		binary.LittleEndian.PutUint32(p[off:], uint32(pixels[i]))
2291		off += 4
2292	}
2293	return seq
2294}
2295
2296func LookupColor(b *xturbo.Buf, cmap Colormap, name string) xturbo.Seq {
2297	if uint64(len(name)) > 65535 {
2298		b.Fail(xturbo.ErrBadLength)
2299		return 0
2300	}
2301	size := 0
2302	size += 4
2303	size += 2
2304	size += 2
2305	size += len(name) * 1
2306	size = (size + 3) &^ 3
2307	p, seq := b.Request(92, 0, size)
2308	if p == nil {
2309		return 0
2310	}
2311	off := 0
2312	binary.LittleEndian.PutUint32(p[off:], uint32(cmap))
2313	off += 4
2314	binary.LittleEndian.PutUint16(p[off:], uint16(len(name)))
2315	off += 2
2316	off += 2
2317	copy(p[off:], name)
2318	off += len(name)
2319	return seq
2320}
2321
2322func CreateCursor(b *xturbo.Buf, cid Cursor, source Pixmap, mask Pixmap, foreRed uint16, foreGreen uint16, foreBlue uint16, backRed uint16, backGreen uint16, backBlue uint16, x uint16, y uint16) xturbo.Seq {
2323	p, seq := b.Request(93, 0, 28)
2324	if p == nil {
2325		return 0
2326	}
2327	binary.LittleEndian.PutUint32(p[0:], uint32(cid))
2328	binary.LittleEndian.PutUint32(p[4:], uint32(source))
2329	binary.LittleEndian.PutUint32(p[8:], uint32(mask))
2330	binary.LittleEndian.PutUint16(p[12:], uint16(foreRed))
2331	binary.LittleEndian.PutUint16(p[14:], uint16(foreGreen))
2332	binary.LittleEndian.PutUint16(p[16:], uint16(foreBlue))
2333	binary.LittleEndian.PutUint16(p[18:], uint16(backRed))
2334	binary.LittleEndian.PutUint16(p[20:], uint16(backGreen))
2335	binary.LittleEndian.PutUint16(p[22:], uint16(backBlue))
2336	binary.LittleEndian.PutUint16(p[24:], uint16(x))
2337	binary.LittleEndian.PutUint16(p[26:], uint16(y))
2338	return seq
2339}
2340
2341func CreateGlyphCursor(b *xturbo.Buf, cid Cursor, sourceFont Font, maskFont Font, sourceChar uint16, maskChar uint16, foreRed uint16, foreGreen uint16, foreBlue uint16, backRed uint16, backGreen uint16, backBlue uint16) xturbo.Seq {
2342	p, seq := b.Request(94, 0, 28)
2343	if p == nil {
2344		return 0
2345	}
2346	binary.LittleEndian.PutUint32(p[0:], uint32(cid))
2347	binary.LittleEndian.PutUint32(p[4:], uint32(sourceFont))
2348	binary.LittleEndian.PutUint32(p[8:], uint32(maskFont))
2349	binary.LittleEndian.PutUint16(p[12:], uint16(sourceChar))
2350	binary.LittleEndian.PutUint16(p[14:], uint16(maskChar))
2351	binary.LittleEndian.PutUint16(p[16:], uint16(foreRed))
2352	binary.LittleEndian.PutUint16(p[18:], uint16(foreGreen))
2353	binary.LittleEndian.PutUint16(p[20:], uint16(foreBlue))
2354	binary.LittleEndian.PutUint16(p[22:], uint16(backRed))
2355	binary.LittleEndian.PutUint16(p[24:], uint16(backGreen))
2356	binary.LittleEndian.PutUint16(p[26:], uint16(backBlue))
2357	return seq
2358}
2359
2360func FreeCursor(b *xturbo.Buf, cursor Cursor) xturbo.Seq {
2361	p, seq := b.Request(95, 0, 4)
2362	if p == nil {
2363		return 0
2364	}
2365	binary.LittleEndian.PutUint32(p[0:], uint32(cursor))
2366	return seq
2367}
2368
2369func RecolorCursor(b *xturbo.Buf, cursor Cursor, foreRed uint16, foreGreen uint16, foreBlue uint16, backRed uint16, backGreen uint16, backBlue uint16) xturbo.Seq {
2370	p, seq := b.Request(96, 0, 16)
2371	if p == nil {
2372		return 0
2373	}
2374	binary.LittleEndian.PutUint32(p[0:], uint32(cursor))
2375	binary.LittleEndian.PutUint16(p[4:], uint16(foreRed))
2376	binary.LittleEndian.PutUint16(p[6:], uint16(foreGreen))
2377	binary.LittleEndian.PutUint16(p[8:], uint16(foreBlue))
2378	binary.LittleEndian.PutUint16(p[10:], uint16(backRed))
2379	binary.LittleEndian.PutUint16(p[12:], uint16(backGreen))
2380	binary.LittleEndian.PutUint16(p[14:], uint16(backBlue))
2381	return seq
2382}
2383
2384func QueryBestSize(b *xturbo.Buf, class QueryShapeOf, drawable Drawable, width uint16, height uint16) xturbo.Seq {
2385	p, seq := b.Request(97, uint8(int(class)), 8)
2386	if p == nil {
2387		return 0
2388	}
2389	binary.LittleEndian.PutUint32(p[0:], uint32(drawable))
2390	binary.LittleEndian.PutUint16(p[4:], uint16(width))
2391	binary.LittleEndian.PutUint16(p[6:], uint16(height))
2392	return seq
2393}
2394
2395func QueryExtension(b *xturbo.Buf, name string) xturbo.Seq {
2396	if uint64(len(name)) > 65535 {
2397		b.Fail(xturbo.ErrBadLength)
2398		return 0
2399	}
2400	size := 0
2401	size += 2
2402	size += 2
2403	size += len(name) * 1
2404	size = (size + 3) &^ 3
2405	p, seq := b.Request(98, 0, size)
2406	if p == nil {
2407		return 0
2408	}
2409	off := 0
2410	binary.LittleEndian.PutUint16(p[off:], uint16(len(name)))
2411	off += 2
2412	off += 2
2413	copy(p[off:], name)
2414	off += len(name)
2415	return seq
2416}
2417
2418func ListExtensions(b *xturbo.Buf) xturbo.Seq {
2419	p, seq := b.Request(99, 0, 0)
2420	if p == nil {
2421		return 0
2422	}
2423	return seq
2424}
2425
2426func ChangeKeyboardMapping(b *xturbo.Buf, keycodeCount uint8, firstKeycode Keycode, keysymsPerKeycode uint8, keysyms []Keysym) xturbo.Seq {
2427	if len(keysyms) != (int(keycodeCount) * int(keysymsPerKeycode)) {
2428		b.Fail(xturbo.ErrBadLength)
2429		return 0
2430	}
2431	size := 0
2432	size += 1
2433	size += 1
2434	size += 2
2435	size += len(keysyms) * 4
2436	size = (size + 3) &^ 3
2437	p, seq := b.Request(100, uint8(int(keycodeCount)), size)
2438	if p == nil {
2439		return 0
2440	}
2441	off := 0
2442	p[off:][0] = byte(firstKeycode)
2443	off += 1
2444	p[off:][0] = byte(keysymsPerKeycode)
2445	off += 1
2446	off += 2
2447	for i := range keysyms {
2448		binary.LittleEndian.PutUint32(p[off:], uint32(keysyms[i]))
2449		off += 4
2450	}
2451	return seq
2452}
2453
2454func GetKeyboardMapping(b *xturbo.Buf, firstKeycode Keycode, count uint8) xturbo.Seq {
2455	p, seq := b.Request(101, 0, 4)
2456	if p == nil {
2457		return 0
2458	}
2459	p[0:][0] = byte(firstKeycode)
2460	p[1:][0] = byte(count)
2461	return seq
2462}
2463
2464type ChangeKeyboardControlValues struct {
2465	Mask            Kb
2466	KeyClickPercent int32
2467	BellPercent     int32
2468	BellPitch       int32
2469	BellDuration    int32
2470	Led             uint32
2471	LedMode         LedMode
2472	Key             Keycode32
2473	AutoRepeatMode  AutoRepeatMode
2474}
2475
2476func (v *ChangeKeyboardControlValues) SetKeyClickPercent(x int32) *ChangeKeyboardControlValues {
2477	v.Mask |= KbKeyClickPercent
2478	v.KeyClickPercent = x
2479	return v
2480}
2481func (v *ChangeKeyboardControlValues) SetBellPercent(x int32) *ChangeKeyboardControlValues {
2482	v.Mask |= KbBellPercent
2483	v.BellPercent = x
2484	return v
2485}
2486func (v *ChangeKeyboardControlValues) SetBellPitch(x int32) *ChangeKeyboardControlValues {
2487	v.Mask |= KbBellPitch
2488	v.BellPitch = x
2489	return v
2490}
2491func (v *ChangeKeyboardControlValues) SetBellDuration(x int32) *ChangeKeyboardControlValues {
2492	v.Mask |= KbBellDuration
2493	v.BellDuration = x
2494	return v
2495}
2496func (v *ChangeKeyboardControlValues) SetLed(x uint32) *ChangeKeyboardControlValues {
2497	v.Mask |= KbLed
2498	v.Led = x
2499	return v
2500}
2501func (v *ChangeKeyboardControlValues) SetLedMode(x LedMode) *ChangeKeyboardControlValues {
2502	v.Mask |= KbLedMode
2503	v.LedMode = x
2504	return v
2505}
2506func (v *ChangeKeyboardControlValues) SetKey(x Keycode32) *ChangeKeyboardControlValues {
2507	v.Mask |= KbKey
2508	v.Key = x
2509	return v
2510}
2511func (v *ChangeKeyboardControlValues) SetAutoRepeatMode(x AutoRepeatMode) *ChangeKeyboardControlValues {
2512	v.Mask |= KbAutoRepeatMode
2513	v.AutoRepeatMode = x
2514	return v
2515}
2516func ChangeKeyboardControl(b *xturbo.Buf, v *ChangeKeyboardControlValues) xturbo.Seq {
2517	p, seq := b.Request(102, 0, 4+4*bits.OnesCount32(uint32(v.Mask)))
2518	if p == nil {
2519		return 0
2520	}
2521	binary.LittleEndian.PutUint32(p[0:], uint32(v.Mask))
2522	off := 4
2523	if v.Mask&KbKeyClickPercent != 0 {
2524		binary.LittleEndian.PutUint32(p[off:], uint32(v.KeyClickPercent))
2525		off += 4
2526	}
2527	if v.Mask&KbBellPercent != 0 {
2528		binary.LittleEndian.PutUint32(p[off:], uint32(v.BellPercent))
2529		off += 4
2530	}
2531	if v.Mask&KbBellPitch != 0 {
2532		binary.LittleEndian.PutUint32(p[off:], uint32(v.BellPitch))
2533		off += 4
2534	}
2535	if v.Mask&KbBellDuration != 0 {
2536		binary.LittleEndian.PutUint32(p[off:], uint32(v.BellDuration))
2537		off += 4
2538	}
2539	if v.Mask&KbLed != 0 {
2540		binary.LittleEndian.PutUint32(p[off:], uint32(v.Led))
2541		off += 4
2542	}
2543	if v.Mask&KbLedMode != 0 {
2544		binary.LittleEndian.PutUint32(p[off:], uint32(v.LedMode))
2545		off += 4
2546	}
2547	if v.Mask&KbKey != 0 {
2548		binary.LittleEndian.PutUint32(p[off:], uint32(v.Key))
2549		off += 4
2550	}
2551	if v.Mask&KbAutoRepeatMode != 0 {
2552		binary.LittleEndian.PutUint32(p[off:], uint32(v.AutoRepeatMode))
2553		off += 4
2554	}
2555	_ = off
2556	return seq
2557}
2558
2559func GetKeyboardControl(b *xturbo.Buf) xturbo.Seq {
2560	p, seq := b.Request(103, 0, 0)
2561	if p == nil {
2562		return 0
2563	}
2564	return seq
2565}
2566
2567func Bell(b *xturbo.Buf, percent int8) xturbo.Seq {
2568	p, seq := b.Request(104, uint8(int(percent)), 0)
2569	if p == nil {
2570		return 0
2571	}
2572	return seq
2573}
2574
2575func ChangePointerControl(b *xturbo.Buf, accelerationNumerator int16, accelerationDenominator int16, threshold int16, doAcceleration bool, doThreshold bool) xturbo.Seq {
2576	p, seq := b.Request(105, 0, 8)
2577	if p == nil {
2578		return 0
2579	}
2580	binary.LittleEndian.PutUint16(p[0:], uint16(accelerationNumerator))
2581	binary.LittleEndian.PutUint16(p[2:], uint16(accelerationDenominator))
2582	binary.LittleEndian.PutUint16(p[4:], uint16(threshold))
2583	if doAcceleration {
2584		p[6:][0] = 1
2585	} else {
2586		p[6:][0] = 0
2587	}
2588	if doThreshold {
2589		p[7:][0] = 1
2590	} else {
2591		p[7:][0] = 0
2592	}
2593	return seq
2594}
2595
2596func GetPointerControl(b *xturbo.Buf) xturbo.Seq {
2597	p, seq := b.Request(106, 0, 0)
2598	if p == nil {
2599		return 0
2600	}
2601	return seq
2602}
2603
2604func SetScreenSaver(b *xturbo.Buf, timeout int16, interval int16, preferBlanking Blanking, allowExposures Exposures) xturbo.Seq {
2605	p, seq := b.Request(107, 0, 8)
2606	if p == nil {
2607		return 0
2608	}
2609	binary.LittleEndian.PutUint16(p[0:], uint16(timeout))
2610	binary.LittleEndian.PutUint16(p[2:], uint16(interval))
2611	p[4:][0] = byte(preferBlanking)
2612	p[5:][0] = byte(allowExposures)
2613	return seq
2614}
2615
2616func GetScreenSaver(b *xturbo.Buf) xturbo.Seq {
2617	p, seq := b.Request(108, 0, 0)
2618	if p == nil {
2619		return 0
2620	}
2621	return seq
2622}
2623
2624func ChangeHosts(b *xturbo.Buf, mode HostMode, family Family, address []byte) xturbo.Seq {
2625	if uint64(len(address)) > 65535 {
2626		b.Fail(xturbo.ErrBadLength)
2627		return 0
2628	}
2629	size := 0
2630	size += 1
2631	size += 1
2632	size += 2
2633	size += len(address) * 1
2634	size = (size + 3) &^ 3
2635	p, seq := b.Request(109, uint8(int(mode)), size)
2636	if p == nil {
2637		return 0
2638	}
2639	off := 0
2640	p[off:][0] = byte(family)
2641	off += 1
2642	off += 1
2643	binary.LittleEndian.PutUint16(p[off:], uint16(len(address)))
2644	off += 2
2645	copy(p[off:], address)
2646	off += len(address)
2647	return seq
2648}
2649
2650func ListHosts(b *xturbo.Buf) xturbo.Seq {
2651	p, seq := b.Request(110, 0, 0)
2652	if p == nil {
2653		return 0
2654	}
2655	return seq
2656}
2657
2658func SetAccessControl(b *xturbo.Buf, mode AccessControl) xturbo.Seq {
2659	p, seq := b.Request(111, uint8(int(mode)), 0)
2660	if p == nil {
2661		return 0
2662	}
2663	return seq
2664}
2665
2666func SetCloseDownMode(b *xturbo.Buf, mode CloseDown) xturbo.Seq {
2667	p, seq := b.Request(112, uint8(int(mode)), 0)
2668	if p == nil {
2669		return 0
2670	}
2671	return seq
2672}
2673
2674func KillClient(b *xturbo.Buf, resource uint32) xturbo.Seq {
2675	p, seq := b.Request(113, 0, 4)
2676	if p == nil {
2677		return 0
2678	}
2679	binary.LittleEndian.PutUint32(p[0:], uint32(resource))
2680	return seq
2681}
2682
2683func RotateProperties(b *xturbo.Buf, window Window, delta int16, atoms []Atom) xturbo.Seq {
2684	if uint64(len(atoms)) > 65535 {
2685		b.Fail(xturbo.ErrBadLength)
2686		return 0
2687	}
2688	size := 0
2689	size += 4
2690	size += 2
2691	size += 2
2692	size += len(atoms) * 4
2693	size = (size + 3) &^ 3
2694	p, seq := b.Request(114, 0, size)
2695	if p == nil {
2696		return 0
2697	}
2698	off := 0
2699	binary.LittleEndian.PutUint32(p[off:], uint32(window))
2700	off += 4
2701	binary.LittleEndian.PutUint16(p[off:], uint16(len(atoms)))
2702	off += 2
2703	binary.LittleEndian.PutUint16(p[off:], uint16(delta))
2704	off += 2
2705	for i := range atoms {
2706		binary.LittleEndian.PutUint32(p[off:], uint32(atoms[i]))
2707		off += 4
2708	}
2709	return seq
2710}
2711
2712func ForceScreenSaver(b *xturbo.Buf, mode ScreenSaver) xturbo.Seq {
2713	p, seq := b.Request(115, uint8(int(mode)), 0)
2714	if p == nil {
2715		return 0
2716	}
2717	return seq
2718}
2719
2720func SetPointerMapping(b *xturbo.Buf, map_ []byte) xturbo.Seq {
2721	if len(map_) > 255 {
2722		b.Fail(xturbo.ErrBadLength)
2723		return 0
2724	}
2725	size := 0
2726	size += len(map_) * 1
2727	size = (size + 3) &^ 3
2728	p, seq := b.Request(116, uint8(len(map_)), size)
2729	if p == nil {
2730		return 0
2731	}
2732	off := 0
2733	copy(p[off:], map_)
2734	off += len(map_)
2735	return seq
2736}
2737
2738func GetPointerMapping(b *xturbo.Buf) xturbo.Seq {
2739	p, seq := b.Request(117, 0, 0)
2740	if p == nil {
2741		return 0
2742	}
2743	return seq
2744}
2745
2746func SetModifierMapping(b *xturbo.Buf, keycodesPerModifier uint8, keycodes []Keycode) xturbo.Seq {
2747	if len(keycodes) != (int(keycodesPerModifier) * 8) {
2748		b.Fail(xturbo.ErrBadLength)
2749		return 0
2750	}
2751	size := 0
2752	size += len(keycodes) * 1
2753	size = (size + 3) &^ 3
2754	p, seq := b.Request(118, uint8(int(keycodesPerModifier)), size)
2755	if p == nil {
2756		return 0
2757	}
2758	off := 0
2759	for i := range keycodes {
2760		p[off:][0] = byte(keycodes[i])
2761		off += 1
2762	}
2763	return seq
2764}
2765
2766func GetModifierMapping(b *xturbo.Buf) xturbo.Seq {
2767	p, seq := b.Request(119, 0, 0)
2768	if p == nil {
2769		return 0
2770	}
2771	return seq
2772}
2773
2774func NoOperation(b *xturbo.Buf) xturbo.Seq {
2775	p, seq := b.Request(127, 0, 0)
2776	if p == nil {
2777		return 0
2778	}
2779	return seq
2780}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 1

↑↓ moveenter openesc close