1import xcffib
2import struct
3import six
4MAJOR_VERSION = 0
5MINOR_VERSION = 11
6key = xcffib.ExtensionKey("RENDER")
7_events = {}
8_errors = {}
9from . import xproto
10class PictType:
11    Indexed = 0
12    Direct = 1
13class Picture:
14    _None = 0
15class PictOp:
16    Clear = 0
17    Src = 1
18    Dst = 2
19    Over = 3
20    OverReverse = 4
21    In = 5
22    InReverse = 6
23    Out = 7
24    OutReverse = 8
25    Atop = 9
26    AtopReverse = 10
27    Xor = 11
28    Add = 12
29    Saturate = 13
30    DisjointClear = 16
31    DisjointSrc = 17
32    DisjointDst = 18
33    DisjointOver = 19
34    DisjointOverReverse = 20
35    DisjointIn = 21
36    DisjointInReverse = 22
37    DisjointOut = 23
38    DisjointOutReverse = 24
39    DisjointAtop = 25
40    DisjointAtopReverse = 26
41    DisjointXor = 27
42    ConjointClear = 32
43    ConjointSrc = 33
44    ConjointDst = 34
45    ConjointOver = 35
46    ConjointOverReverse = 36
47    ConjointIn = 37
48    ConjointInReverse = 38
49    ConjointOut = 39
50    ConjointOutReverse = 40
51    ConjointAtop = 41
52    ConjointAtopReverse = 42
53    ConjointXor = 43
54    Multiply = 48
55    Screen = 49
56    Overlay = 50
57    Darken = 51
58    Lighten = 52
59    ColorDodge = 53
60    ColorBurn = 54
61    HardLight = 55
62    SoftLight = 56
63    Difference = 57
64    Exclusion = 58
65    HSLHue = 59
66    HSLSaturation = 60
67    HSLColor = 61
68    HSLLuminosity = 62
69class PolyEdge:
70    Sharp = 0
71    Smooth = 1
72class PolyMode:
73    Precise = 0
74    Imprecise = 1
75class CP:
76    Repeat = 1 << 0
77    AlphaMap = 1 << 1
78    AlphaXOrigin = 1 << 2
79    AlphaYOrigin = 1 << 3
80    ClipXOrigin = 1 << 4
81    ClipYOrigin = 1 << 5
82    ClipMask = 1 << 6
83    GraphicsExposure = 1 << 7
84    SubwindowMode = 1 << 8
85    PolyEdge = 1 << 9
86    PolyMode = 1 << 10
87    Dither = 1 << 11
88    ComponentAlpha = 1 << 12
89class SubPixel:
90    Unknown = 0
91    HorizontalRGB = 1
92    HorizontalBGR = 2
93    VerticalRGB = 3
94    VerticalBGR = 4
95    _None = 5
96class Repeat:
97    _None = 0
98    Normal = 1
99    Pad = 2
100    Reflect = 3
101class PictFormatError(xcffib.Error):
102    def __init__(self, unpacker):
103        if isinstance(unpacker, xcffib.Protobj):
104            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
105        xcffib.Error.__init__(self, unpacker)
106        base = unpacker.offset
107        unpacker.unpack("xx2x")
108        self.bufsize = unpacker.offset - base
109    def pack(self):
110        buf = six.BytesIO()
111        buf.write(struct.pack("=B", 0))
112        buf.write(struct.pack("=x2x"))
113        return buf.getvalue()
114BadPictFormat = PictFormatError
115_errors[0] = PictFormatError
116class PictureError(xcffib.Error):
117    def __init__(self, unpacker):
118        if isinstance(unpacker, xcffib.Protobj):
119            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
120        xcffib.Error.__init__(self, unpacker)
121        base = unpacker.offset
122        unpacker.unpack("xx2x")
123        self.bufsize = unpacker.offset - base
124    def pack(self):
125        buf = six.BytesIO()
126        buf.write(struct.pack("=B", 1))
127        buf.write(struct.pack("=x2x"))
128        return buf.getvalue()
129BadPicture = PictureError
130_errors[1] = PictureError
131class PictOpError(xcffib.Error):
132    def __init__(self, unpacker):
133        if isinstance(unpacker, xcffib.Protobj):
134            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
135        xcffib.Error.__init__(self, unpacker)
136        base = unpacker.offset
137        unpacker.unpack("xx2x")
138        self.bufsize = unpacker.offset - base
139    def pack(self):
140        buf = six.BytesIO()
141        buf.write(struct.pack("=B", 2))
142        buf.write(struct.pack("=x2x"))
143        return buf.getvalue()
144BadPictOp = PictOpError
145_errors[2] = PictOpError
146class GlyphSetError(xcffib.Error):
147    def __init__(self, unpacker):
148        if isinstance(unpacker, xcffib.Protobj):
149            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
150        xcffib.Error.__init__(self, unpacker)
151        base = unpacker.offset
152        unpacker.unpack("xx2x")
153        self.bufsize = unpacker.offset - base
154    def pack(self):
155        buf = six.BytesIO()
156        buf.write(struct.pack("=B", 3))
157        buf.write(struct.pack("=x2x"))
158        return buf.getvalue()
159BadGlyphSet = GlyphSetError
160_errors[3] = GlyphSetError
161class GlyphError(xcffib.Error):
162    def __init__(self, unpacker):
163        if isinstance(unpacker, xcffib.Protobj):
164            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
165        xcffib.Error.__init__(self, unpacker)
166        base = unpacker.offset
167        unpacker.unpack("xx2x")
168        self.bufsize = unpacker.offset - base
169    def pack(self):
170        buf = six.BytesIO()
171        buf.write(struct.pack("=B", 4))
172        buf.write(struct.pack("=x2x"))
173        return buf.getvalue()
174BadGlyph = GlyphError
175_errors[4] = GlyphError
176class DIRECTFORMAT(xcffib.Struct):
177    def __init__(self, unpacker):
178        if isinstance(unpacker, xcffib.Protobj):
179            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
180        xcffib.Struct.__init__(self, unpacker)
181        base = unpacker.offset
182        self.red_shift, self.red_mask, self.green_shift, self.green_mask, self.blue_shift, self.blue_mask, self.alpha_shift, self.alpha_mask = unpacker.unpack("HHHHHHHH")
183        self.bufsize = unpacker.offset - base
184    def pack(self):
185        buf = six.BytesIO()
186        buf.write(struct.pack("=HHHHHHHH", self.red_shift, self.red_mask, self.green_shift, self.green_mask, self.blue_shift, self.blue_mask, self.alpha_shift, self.alpha_mask))
187        return buf.getvalue()
188    fixed_size = 16
189    @classmethod
190    def synthetic(cls, red_shift, red_mask, green_shift, green_mask, blue_shift, blue_mask, alpha_shift, alpha_mask):
191        self = cls.__new__(cls)
192        self.red_shift = red_shift
193        self.red_mask = red_mask
194        self.green_shift = green_shift
195        self.green_mask = green_mask
196        self.blue_shift = blue_shift
197        self.blue_mask = blue_mask
198        self.alpha_shift = alpha_shift
199        self.alpha_mask = alpha_mask
200        return self
201class PICTFORMINFO(xcffib.Struct):
202    def __init__(self, unpacker):
203        if isinstance(unpacker, xcffib.Protobj):
204            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
205        xcffib.Struct.__init__(self, unpacker)
206        base = unpacker.offset
207        self.id, self.type, self.depth = unpacker.unpack("IBB2x")
208        self.direct = DIRECTFORMAT(unpacker)
209        self.colormap, = unpacker.unpack("I")
210        self.bufsize = unpacker.offset - base
211    def pack(self):
212        buf = six.BytesIO()
213        buf.write(struct.pack("=IBB2xI", self.id, self.type, self.depth, self.colormap))
214        buf.write(self.direct.pack() if hasattr(self.direct, "pack") else DIRECTFORMAT.synthetic(*self.direct).pack())
215        return buf.getvalue()
216    @classmethod
217    def synthetic(cls, id, type, depth, direct, colormap):
218        self = cls.__new__(cls)
219        self.id = id
220        self.type = type
221        self.depth = depth
222        self.direct = direct
223        self.colormap = colormap
224        return self
225class PICTVISUAL(xcffib.Struct):
226    def __init__(self, unpacker):
227        if isinstance(unpacker, xcffib.Protobj):
228            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
229        xcffib.Struct.__init__(self, unpacker)
230        base = unpacker.offset
231        self.visual, self.format = unpacker.unpack("II")
232        self.bufsize = unpacker.offset - base
233    def pack(self):
234        buf = six.BytesIO()
235        buf.write(struct.pack("=II", self.visual, self.format))
236        return buf.getvalue()
237    fixed_size = 8
238    @classmethod
239    def synthetic(cls, visual, format):
240        self = cls.__new__(cls)
241        self.visual = visual
242        self.format = format
243        return self
244class PICTDEPTH(xcffib.Struct):
245    def __init__(self, unpacker):
246        if isinstance(unpacker, xcffib.Protobj):
247            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
248        xcffib.Struct.__init__(self, unpacker)
249        base = unpacker.offset
250        self.depth, self.num_visuals = unpacker.unpack("BxH4x")
251        self.visuals = xcffib.List(unpacker, PICTVISUAL, self.num_visuals)
252        self.bufsize = unpacker.offset - base
253    def pack(self):
254        buf = six.BytesIO()
255        buf.write(struct.pack("=BxH4x", self.depth, self.num_visuals))
256        buf.write(xcffib.pack_list(self.visuals, PICTVISUAL))
257        return buf.getvalue()
258    @classmethod
259    def synthetic(cls, depth, num_visuals, visuals):
260        self = cls.__new__(cls)
261        self.depth = depth
262        self.num_visuals = num_visuals
263        self.visuals = visuals
264        return self
265class PICTSCREEN(xcffib.Struct):
266    def __init__(self, unpacker):
267        if isinstance(unpacker, xcffib.Protobj):
268            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
269        xcffib.Struct.__init__(self, unpacker)
270        base = unpacker.offset
271        self.num_depths, self.fallback = unpacker.unpack("II")
272        self.depths = xcffib.List(unpacker, PICTDEPTH, self.num_depths)
273        self.bufsize = unpacker.offset - base
274    def pack(self):
275        buf = six.BytesIO()
276        buf.write(struct.pack("=II", self.num_depths, self.fallback))
277        buf.write(xcffib.pack_list(self.depths, PICTDEPTH))
278        return buf.getvalue()
279    @classmethod
280    def synthetic(cls, num_depths, fallback, depths):
281        self = cls.__new__(cls)
282        self.num_depths = num_depths
283        self.fallback = fallback
284        self.depths = depths
285        return self
286class INDEXVALUE(xcffib.Struct):
287    def __init__(self, unpacker):
288        if isinstance(unpacker, xcffib.Protobj):
289            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
290        xcffib.Struct.__init__(self, unpacker)
291        base = unpacker.offset
292        self.pixel, self.red, self.green, self.blue, self.alpha = unpacker.unpack("IHHHH")
293        self.bufsize = unpacker.offset - base
294    def pack(self):
295        buf = six.BytesIO()
296        buf.write(struct.pack("=IHHHH", self.pixel, self.red, self.green, self.blue, self.alpha))
297        return buf.getvalue()
298    fixed_size = 12
299    @classmethod
300    def synthetic(cls, pixel, red, green, blue, alpha):
301        self = cls.__new__(cls)
302        self.pixel = pixel
303        self.red = red
304        self.green = green
305        self.blue = blue
306        self.alpha = alpha
307        return self
308class COLOR(xcffib.Struct):
309    def __init__(self, unpacker):
310        if isinstance(unpacker, xcffib.Protobj):
311            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
312        xcffib.Struct.__init__(self, unpacker)
313        base = unpacker.offset
314        self.red, self.green, self.blue, self.alpha = unpacker.unpack("HHHH")
315        self.bufsize = unpacker.offset - base
316    def pack(self):
317        buf = six.BytesIO()
318        buf.write(struct.pack("=HHHH", self.red, self.green, self.blue, self.alpha))
319        return buf.getvalue()
320    fixed_size = 8
321    @classmethod
322    def synthetic(cls, red, green, blue, alpha):
323        self = cls.__new__(cls)
324        self.red = red
325        self.green = green
326        self.blue = blue
327        self.alpha = alpha
328        return self
329class POINTFIX(xcffib.Struct):
330    def __init__(self, unpacker):
331        if isinstance(unpacker, xcffib.Protobj):
332            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
333        xcffib.Struct.__init__(self, unpacker)
334        base = unpacker.offset
335        self.x, self.y = unpacker.unpack("ii")
336        self.bufsize = unpacker.offset - base
337    def pack(self):
338        buf = six.BytesIO()
339        buf.write(struct.pack("=ii", self.x, self.y))
340        return buf.getvalue()
341    fixed_size = 8
342    @classmethod
343    def synthetic(cls, x, y):
344        self = cls.__new__(cls)
345        self.x = x
346        self.y = y
347        return self
348class LINEFIX(xcffib.Struct):
349    def __init__(self, unpacker):
350        if isinstance(unpacker, xcffib.Protobj):
351            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
352        xcffib.Struct.__init__(self, unpacker)
353        base = unpacker.offset
354        self.p1 = POINTFIX(unpacker)
355        unpacker.pad(POINTFIX)
356        self.p2 = POINTFIX(unpacker)
357        self.bufsize = unpacker.offset - base
358    def pack(self):
359        buf = six.BytesIO()
360        buf.write(self.p1.pack() if hasattr(self.p1, "pack") else POINTFIX.synthetic(*self.p1).pack())
361        buf.write(self.p2.pack() if hasattr(self.p2, "pack") else POINTFIX.synthetic(*self.p2).pack())
362        return buf.getvalue()
363    @classmethod
364    def synthetic(cls, p1, p2):
365        self = cls.__new__(cls)
366        self.p1 = p1
367        self.p2 = p2
368        return self
369class TRIANGLE(xcffib.Struct):
370    def __init__(self, unpacker):
371        if isinstance(unpacker, xcffib.Protobj):
372            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
373        xcffib.Struct.__init__(self, unpacker)
374        base = unpacker.offset
375        self.p1 = POINTFIX(unpacker)
376        unpacker.pad(POINTFIX)
377        self.p2 = POINTFIX(unpacker)
378        unpacker.pad(POINTFIX)
379        self.p3 = POINTFIX(unpacker)
380        self.bufsize = unpacker.offset - base
381    def pack(self):
382        buf = six.BytesIO()
383        buf.write(self.p1.pack() if hasattr(self.p1, "pack") else POINTFIX.synthetic(*self.p1).pack())
384        buf.write(self.p2.pack() if hasattr(self.p2, "pack") else POINTFIX.synthetic(*self.p2).pack())
385        buf.write(self.p3.pack() if hasattr(self.p3, "pack") else POINTFIX.synthetic(*self.p3).pack())
386        return buf.getvalue()
387    @classmethod
388    def synthetic(cls, p1, p2, p3):
389        self = cls.__new__(cls)
390        self.p1 = p1
391        self.p2 = p2
392        self.p3 = p3
393        return self
394class TRAPEZOID(xcffib.Struct):
395    def __init__(self, unpacker):
396        if isinstance(unpacker, xcffib.Protobj):
397            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
398        xcffib.Struct.__init__(self, unpacker)
399        base = unpacker.offset
400        self.top, self.bottom = unpacker.unpack("ii")
401        self.left = LINEFIX(unpacker)
402        unpacker.pad(LINEFIX)
403        self.right = LINEFIX(unpacker)
404        self.bufsize = unpacker.offset - base
405    def pack(self):
406        buf = six.BytesIO()
407        buf.write(struct.pack("=ii", self.top, self.bottom))
408        buf.write(self.left.pack() if hasattr(self.left, "pack") else LINEFIX.synthetic(*self.left).pack())
409        buf.write(self.right.pack() if hasattr(self.right, "pack") else LINEFIX.synthetic(*self.right).pack())
410        return buf.getvalue()
411    @classmethod
412    def synthetic(cls, top, bottom, left, right):
413        self = cls.__new__(cls)
414        self.top = top
415        self.bottom = bottom
416        self.left = left
417        self.right = right
418        return self
419class GLYPHINFO(xcffib.Struct):
420    def __init__(self, unpacker):
421        if isinstance(unpacker, xcffib.Protobj):
422            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
423        xcffib.Struct.__init__(self, unpacker)
424        base = unpacker.offset
425        self.width, self.height, self.x, self.y, self.x_off, self.y_off = unpacker.unpack("HHhhhh")
426        self.bufsize = unpacker.offset - base
427    def pack(self):
428        buf = six.BytesIO()
429        buf.write(struct.pack("=HHhhhh", self.width, self.height, self.x, self.y, self.x_off, self.y_off))
430        return buf.getvalue()
431    fixed_size = 12
432    @classmethod
433    def synthetic(cls, width, height, x, y, x_off, y_off):
434        self = cls.__new__(cls)
435        self.width = width
436        self.height = height
437        self.x = x
438        self.y = y
439        self.x_off = x_off
440        self.y_off = y_off
441        return self
442class QueryVersionReply(xcffib.Reply):
443    def __init__(self, unpacker):
444        if isinstance(unpacker, xcffib.Protobj):
445            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
446        xcffib.Reply.__init__(self, unpacker)
447        base = unpacker.offset
448        self.major_version, self.minor_version = unpacker.unpack("xx2x4xII16x")
449        self.bufsize = unpacker.offset - base
450class QueryVersionCookie(xcffib.Cookie):
451    reply_type = QueryVersionReply
452class QueryPictFormatsReply(xcffib.Reply):
453    def __init__(self, unpacker):
454        if isinstance(unpacker, xcffib.Protobj):
455            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
456        xcffib.Reply.__init__(self, unpacker)
457        base = unpacker.offset
458        self.num_formats, self.num_screens, self.num_depths, self.num_visuals, self.num_subpixel = unpacker.unpack("xx2x4xIIIII4x")
459        self.formats = xcffib.List(unpacker, PICTFORMINFO, self.num_formats)
460        unpacker.pad(PICTSCREEN)
461        self.screens = xcffib.List(unpacker, PICTSCREEN, self.num_screens)
462        unpacker.pad("I")
463        self.subpixels = xcffib.List(unpacker, "I", self.num_subpixel)
464        self.bufsize = unpacker.offset - base
465class QueryPictFormatsCookie(xcffib.Cookie):
466    reply_type = QueryPictFormatsReply
467class QueryPictIndexValuesReply(xcffib.Reply):
468    def __init__(self, unpacker):
469        if isinstance(unpacker, xcffib.Protobj):
470            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
471        xcffib.Reply.__init__(self, unpacker)
472        base = unpacker.offset
473        self.num_values, = unpacker.unpack("xx2x4xI20x")
474        self.values = xcffib.List(unpacker, INDEXVALUE, self.num_values)
475        self.bufsize = unpacker.offset - base
476class QueryPictIndexValuesCookie(xcffib.Cookie):
477    reply_type = QueryPictIndexValuesReply
478class TRANSFORM(xcffib.Struct):
479    def __init__(self, unpacker):
480        if isinstance(unpacker, xcffib.Protobj):
481            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
482        xcffib.Struct.__init__(self, unpacker)
483        base = unpacker.offset
484        self.matrix11, self.matrix12, self.matrix13, self.matrix21, self.matrix22, self.matrix23, self.matrix31, self.matrix32, self.matrix33 = unpacker.unpack("iiiiiiiii")
485        self.bufsize = unpacker.offset - base
486    def pack(self):
487        buf = six.BytesIO()
488        buf.write(struct.pack("=iiiiiiiii", self.matrix11, self.matrix12, self.matrix13, self.matrix21, self.matrix22, self.matrix23, self.matrix31, self.matrix32, self.matrix33))
489        return buf.getvalue()
490    fixed_size = 36
491    @classmethod
492    def synthetic(cls, matrix11, matrix12, matrix13, matrix21, matrix22, matrix23, matrix31, matrix32, matrix33):
493        self = cls.__new__(cls)
494        self.matrix11 = matrix11
495        self.matrix12 = matrix12
496        self.matrix13 = matrix13
497        self.matrix21 = matrix21
498        self.matrix22 = matrix22
499        self.matrix23 = matrix23
500        self.matrix31 = matrix31
501        self.matrix32 = matrix32
502        self.matrix33 = matrix33
503        return self
504class QueryFiltersReply(xcffib.Reply):
505    def __init__(self, unpacker):
506        if isinstance(unpacker, xcffib.Protobj):
507            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
508        xcffib.Reply.__init__(self, unpacker)
509        base = unpacker.offset
510        self.num_aliases, self.num_filters = unpacker.unpack("xx2x4xII16x")
511        self.aliases = xcffib.List(unpacker, "H", self.num_aliases)
512        unpacker.pad(xproto.STR)
513        self.filters = xcffib.List(unpacker, xproto.STR, self.num_filters)
514        self.bufsize = unpacker.offset - base
515class QueryFiltersCookie(xcffib.Cookie):
516    reply_type = QueryFiltersReply
517class ANIMCURSORELT(xcffib.Struct):
518    def __init__(self, unpacker):
519        if isinstance(unpacker, xcffib.Protobj):
520            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
521        xcffib.Struct.__init__(self, unpacker)
522        base = unpacker.offset
523        self.cursor, self.delay = unpacker.unpack("II")
524        self.bufsize = unpacker.offset - base
525    def pack(self):
526        buf = six.BytesIO()
527        buf.write(struct.pack("=II", self.cursor, self.delay))
528        return buf.getvalue()
529    fixed_size = 8
530    @classmethod
531    def synthetic(cls, cursor, delay):
532        self = cls.__new__(cls)
533        self.cursor = cursor
534        self.delay = delay
535        return self
536class SPANFIX(xcffib.Struct):
537    def __init__(self, unpacker):
538        if isinstance(unpacker, xcffib.Protobj):
539            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
540        xcffib.Struct.__init__(self, unpacker)
541        base = unpacker.offset
542        self.l, self.r, self.y = unpacker.unpack("iii")
543        self.bufsize = unpacker.offset - base
544    def pack(self):
545        buf = six.BytesIO()
546        buf.write(struct.pack("=iii", self.l, self.r, self.y))
547        return buf.getvalue()
548    fixed_size = 12
549    @classmethod
550    def synthetic(cls, l, r, y):
551        self = cls.__new__(cls)
552        self.l = l
553        self.r = r
554        self.y = y
555        return self
556class TRAP(xcffib.Struct):
557    def __init__(self, unpacker):
558        if isinstance(unpacker, xcffib.Protobj):
559            unpacker = xcffib.MemoryUnpacker(unpacker.pack())
560        xcffib.Struct.__init__(self, unpacker)
561        base = unpacker.offset
562        self.top = SPANFIX(unpacker)
563        unpacker.pad(SPANFIX)
564        self.bot = SPANFIX(unpacker)
565        self.bufsize = unpacker.offset - base
566    def pack(self):
567        buf = six.BytesIO()
568        buf.write(self.top.pack() if hasattr(self.top, "pack") else SPANFIX.synthetic(*self.top).pack())
569        buf.write(self.bot.pack() if hasattr(self.bot, "pack") else SPANFIX.synthetic(*self.bot).pack())
570        return buf.getvalue()
571    @classmethod
572    def synthetic(cls, top, bot):
573        self = cls.__new__(cls)
574        self.top = top
575        self.bot = bot
576        return self
577class renderExtension(xcffib.Extension):
578    def QueryVersion(self, client_major_version, client_minor_version, is_checked=True):
579        buf = six.BytesIO()
580        buf.write(struct.pack("=xx2xII", client_major_version, client_minor_version))
581        return self.send_request(0, buf, QueryVersionCookie, is_checked=is_checked)
582    def QueryPictFormats(self, is_checked=True):
583        buf = six.BytesIO()
584        buf.write(struct.pack("=xx2x"))
585        return self.send_request(1, buf, QueryPictFormatsCookie, is_checked=is_checked)
586    def QueryPictIndexValues(self, format, is_checked=True):
587        buf = six.BytesIO()
588        buf.write(struct.pack("=xx2xI", format))
589        return self.send_request(2, buf, QueryPictIndexValuesCookie, is_checked=is_checked)
590    def CreatePicture(self, pid, drawable, format, value_mask, value_list, is_checked=False):
591        buf = six.BytesIO()
592        buf.write(struct.pack("=xx2xIIII", pid, drawable, format, value_mask))
593        if value_mask & CP.Repeat:
594            repeat = value_list.pop(0)
595            buf.write(struct.pack("=I", repeat))
596        if value_mask & CP.AlphaMap:
597            alphamap = value_list.pop(0)
598            buf.write(struct.pack("=I", alphamap))
599        if value_mask & CP.AlphaXOrigin:
600            alphaxorigin = value_list.pop(0)
601            buf.write(struct.pack("=i", alphaxorigin))
602        if value_mask & CP.AlphaYOrigin:
603            alphayorigin = value_list.pop(0)
604            buf.write(struct.pack("=i", alphayorigin))
605        if value_mask & CP.ClipXOrigin:
606            clipxorigin = value_list.pop(0)
607            buf.write(struct.pack("=i", clipxorigin))
608        if value_mask & CP.ClipYOrigin:
609            clipyorigin = value_list.pop(0)
610            buf.write(struct.pack("=i", clipyorigin))
611        if value_mask & CP.ClipMask:
612            clipmask = value_list.pop(0)
613            buf.write(struct.pack("=I", clipmask))
614        if value_mask & CP.GraphicsExposure:
615            graphicsexposure = value_list.pop(0)
616            buf.write(struct.pack("=I", graphicsexposure))
617        if value_mask & CP.SubwindowMode:
618            subwindowmode = value_list.pop(0)
619            buf.write(struct.pack("=I", subwindowmode))
620        if value_mask & CP.PolyEdge:
621            polyedge = value_list.pop(0)
622            buf.write(struct.pack("=I", polyedge))
623        if value_mask & CP.PolyMode:
624            polymode = value_list.pop(0)
625            buf.write(struct.pack("=I", polymode))
626        if value_mask & CP.Dither:
627            dither = value_list.pop(0)
628            buf.write(struct.pack("=I", dither))
629        if value_mask & CP.ComponentAlpha:
630            componentalpha = value_list.pop(0)
631            buf.write(struct.pack("=I", componentalpha))
632        return self.send_request(4, buf, is_checked=is_checked)
633    def ChangePicture(self, picture, value_mask, value_list, is_checked=False):
634        buf = six.BytesIO()
635        buf.write(struct.pack("=xx2xII", picture, value_mask))
636        if value_mask & CP.Repeat:
637            repeat = value_list.pop(0)
638            buf.write(struct.pack("=I", repeat))
639        if value_mask & CP.AlphaMap:
640            alphamap = value_list.pop(0)
641            buf.write(struct.pack("=I", alphamap))
642        if value_mask & CP.AlphaXOrigin:
643            alphaxorigin = value_list.pop(0)
644            buf.write(struct.pack("=i", alphaxorigin))
645        if value_mask & CP.AlphaYOrigin:
646            alphayorigin = value_list.pop(0)
647            buf.write(struct.pack("=i", alphayorigin))
648        if value_mask & CP.ClipXOrigin:
649            clipxorigin = value_list.pop(0)
650            buf.write(struct.pack("=i", clipxorigin))
651        if value_mask & CP.ClipYOrigin:
652            clipyorigin = value_list.pop(0)
653            buf.write(struct.pack("=i", clipyorigin))
654        if value_mask & CP.ClipMask:
655            clipmask = value_list.pop(0)
656            buf.write(struct.pack("=I", clipmask))
657        if value_mask & CP.GraphicsExposure:
658            graphicsexposure = value_list.pop(0)
659            buf.write(struct.pack("=I", graphicsexposure))
660        if value_mask & CP.SubwindowMode:
661            subwindowmode = value_list.pop(0)
662            buf.write(struct.pack("=I", subwindowmode))
663        if value_mask & CP.PolyEdge:
664            polyedge = value_list.pop(0)
665            buf.write(struct.pack("=I", polyedge))
666        if value_mask & CP.PolyMode:
667            polymode = value_list.pop(0)
668            buf.write(struct.pack("=I", polymode))
669        if value_mask & CP.Dither:
670            dither = value_list.pop(0)
671            buf.write(struct.pack("=I", dither))
672        if value_mask & CP.ComponentAlpha:
673            componentalpha = value_list.pop(0)
674            buf.write(struct.pack("=I", componentalpha))
675        return self.send_request(5, buf, is_checked=is_checked)
676    def SetPictureClipRectangles(self, picture, clip_x_origin, clip_y_origin, rectangles_len, rectangles, is_checked=False):
677        buf = six.BytesIO()
678        buf.write(struct.pack("=xx2xIhh", picture, clip_x_origin, clip_y_origin))
679        buf.write(xcffib.pack_list(rectangles, xproto.RECTANGLE))
680        return self.send_request(6, buf, is_checked=is_checked)
681    def FreePicture(self, picture, is_checked=False):
682        buf = six.BytesIO()
683        buf.write(struct.pack("=xx2xI", picture))
684        return self.send_request(7, buf, is_checked=is_checked)
685    def Composite(self, op, src, mask, dst, src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height, is_checked=False):
686        buf = six.BytesIO()
687        buf.write(struct.pack("=xx2xB3xIIIhhhhhhHH", op, src, mask, dst, src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height))
688        return self.send_request(8, buf, is_checked=is_checked)
689    def Trapezoids(self, op, src, dst, mask_format, src_x, src_y, traps_len, traps, is_checked=False):
690        buf = six.BytesIO()
691        buf.write(struct.pack("=xx2xB3xIIIhh", op, src, dst, mask_format, src_x, src_y))
692        buf.write(xcffib.pack_list(traps, TRAPEZOID))
693        return self.send_request(10, buf, is_checked=is_checked)
694    def Triangles(self, op, src, dst, mask_format, src_x, src_y, triangles_len, triangles, is_checked=False):
695        buf = six.BytesIO()
696        buf.write(struct.pack("=xx2xB3xIIIhh", op, src, dst, mask_format, src_x, src_y))
697        buf.write(xcffib.pack_list(triangles, TRIANGLE))
698        return self.send_request(11, buf, is_checked=is_checked)
699    def TriStrip(self, op, src, dst, mask_format, src_x, src_y, points_len, points, is_checked=False):
700        buf = six.BytesIO()
701        buf.write(struct.pack("=xx2xB3xIIIhh", op, src, dst, mask_format, src_x, src_y))
702        buf.write(xcffib.pack_list(points, POINTFIX))
703        return self.send_request(12, buf, is_checked=is_checked)
704    def TriFan(self, op, src, dst, mask_format, src_x, src_y, points_len, points, is_checked=False):
705        buf = six.BytesIO()
706        buf.write(struct.pack("=xx2xB3xIIIhh", op, src, dst, mask_format, src_x, src_y))
707        buf.write(xcffib.pack_list(points, POINTFIX))
708        return self.send_request(13, buf, is_checked=is_checked)
709    def CreateGlyphSet(self, gsid, format, is_checked=False):
710        buf = six.BytesIO()
711        buf.write(struct.pack("=xx2xII", gsid, format))
712        return self.send_request(17, buf, is_checked=is_checked)
713    def ReferenceGlyphSet(self, gsid, existing, is_checked=False):
714        buf = six.BytesIO()
715        buf.write(struct.pack("=xx2xII", gsid, existing))
716        return self.send_request(18, buf, is_checked=is_checked)
717    def FreeGlyphSet(self, glyphset, is_checked=False):
718        buf = six.BytesIO()
719        buf.write(struct.pack("=xx2xI", glyphset))
720        return self.send_request(19, buf, is_checked=is_checked)
721    def AddGlyphs(self, glyphset, glyphs_len, glyphids, glyphs, data_len, data, is_checked=False):
722        buf = six.BytesIO()
723        buf.write(struct.pack("=xx2xII", glyphset, glyphs_len))
724        buf.write(xcffib.pack_list(glyphids, "I"))
725        buf.write(xcffib.pack_list(glyphs, GLYPHINFO))
726        buf.write(xcffib.pack_list(data, "B"))
727        return self.send_request(20, buf, is_checked=is_checked)
728    def FreeGlyphs(self, glyphset, glyphs_len, glyphs, is_checked=False):
729        buf = six.BytesIO()
730        buf.write(struct.pack("=xx2xI", glyphset))
731        buf.write(xcffib.pack_list(glyphs, "I"))
732        return self.send_request(22, buf, is_checked=is_checked)
733    def CompositeGlyphs8(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds_len, glyphcmds, is_checked=False):
734        buf = six.BytesIO()
735        buf.write(struct.pack("=xx2xB3xIIIIhh", op, src, dst, mask_format, glyphset, src_x, src_y))
736        buf.write(xcffib.pack_list(glyphcmds, "B"))
737        return self.send_request(23, buf, is_checked=is_checked)
738    def CompositeGlyphs16(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds_len, glyphcmds, is_checked=False):
739        buf = six.BytesIO()
740        buf.write(struct.pack("=xx2xB3xIIIIhh", op, src, dst, mask_format, glyphset, src_x, src_y))
741        buf.write(xcffib.pack_list(glyphcmds, "B"))
742        return self.send_request(24, buf, is_checked=is_checked)
743    def CompositeGlyphs32(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds_len, glyphcmds, is_checked=False):
744        buf = six.BytesIO()
745        buf.write(struct.pack("=xx2xB3xIIIIhh", op, src, dst, mask_format, glyphset, src_x, src_y))
746        buf.write(xcffib.pack_list(glyphcmds, "B"))
747        return self.send_request(25, buf, is_checked=is_checked)
748    def FillRectangles(self, op, dst, color, rects_len, rects, is_checked=False):
749        buf = six.BytesIO()
750        buf.write(struct.pack("=xx2xB3xI", op, dst))
751        buf.write(color.pack() if hasattr(color, "pack") else COLOR.synthetic(*color).pack())
752        buf.write(xcffib.pack_list(rects, xproto.RECTANGLE))
753        return self.send_request(26, buf, is_checked=is_checked)
754    def CreateCursor(self, cid, source, x, y, is_checked=False):
755        buf = six.BytesIO()
756        buf.write(struct.pack("=xx2xIIHH", cid, source, x, y))
757        return self.send_request(27, buf, is_checked=is_checked)
758    def SetPictureTransform(self, picture, transform, is_checked=False):
759        buf = six.BytesIO()
760        buf.write(struct.pack("=xx2xI", picture))
761        buf.write(transform.pack() if hasattr(transform, "pack") else TRANSFORM.synthetic(*transform).pack())
762        return self.send_request(28, buf, is_checked=is_checked)
763    def QueryFilters(self, drawable, is_checked=True):
764        buf = six.BytesIO()
765        buf.write(struct.pack("=xx2xI", drawable))
766        return self.send_request(29, buf, QueryFiltersCookie, is_checked=is_checked)
767    def SetPictureFilter(self, picture, filter_len, filter, values_len, values, is_checked=False):
768        buf = six.BytesIO()
769        buf.write(struct.pack("=xx2xIH2x", picture, filter_len))
770        buf.write(xcffib.pack_list(filter, "c"))
771        buf.write(xcffib.pack_list(values, "i"))
772        return self.send_request(30, buf, is_checked=is_checked)
773    def CreateAnimCursor(self, cid, cursors_len, cursors, is_checked=False):
774        buf = six.BytesIO()
775        buf.write(struct.pack("=xx2xI", cid))
776        buf.write(xcffib.pack_list(cursors, ANIMCURSORELT))
777        return self.send_request(31, buf, is_checked=is_checked)
778    def AddTraps(self, picture, x_off, y_off, traps_len, traps, is_checked=False):
779        buf = six.BytesIO()
780        buf.write(struct.pack("=xx2xIhh", picture, x_off, y_off))
781        buf.write(xcffib.pack_list(traps, TRAP))
782        return self.send_request(32, buf, is_checked=is_checked)
783    def CreateSolidFill(self, picture, color, is_checked=False):
784        buf = six.BytesIO()
785        buf.write(struct.pack("=xx2xI", picture))
786        buf.write(color.pack() if hasattr(color, "pack") else COLOR.synthetic(*color).pack())
787        return self.send_request(33, buf, is_checked=is_checked)
788    def CreateLinearGradient(self, picture, num_stops, p1, p2, stops, colors, is_checked=False):
789        buf = six.BytesIO()
790        buf.write(struct.pack("=xx2xII", picture, num_stops))
791        buf.write(p1.pack() if hasattr(p1, "pack") else POINTFIX.synthetic(*p1).pack())
792        buf.write(p2.pack() if hasattr(p2, "pack") else POINTFIX.synthetic(*p2).pack())
793        buf.write(xcffib.pack_list(stops, "i"))
794        buf.write(xcffib.pack_list(colors, COLOR))
795        return self.send_request(34, buf, is_checked=is_checked)
796    def CreateRadialGradient(self, picture, inner_radius, outer_radius, num_stops, inner, outer, stops, colors, is_checked=False):
797        buf = six.BytesIO()
798        buf.write(struct.pack("=xx2xIiiI", picture, inner_radius, outer_radius, num_stops))
799        buf.write(inner.pack() if hasattr(inner, "pack") else POINTFIX.synthetic(*inner).pack())
800        buf.write(outer.pack() if hasattr(outer, "pack") else POINTFIX.synthetic(*outer).pack())
801        buf.write(xcffib.pack_list(stops, "i"))
802        buf.write(xcffib.pack_list(colors, COLOR))
803        return self.send_request(35, buf, is_checked=is_checked)
804    def CreateConicalGradient(self, picture, angle, num_stops, center, stops, colors, is_checked=False):
805        buf = six.BytesIO()
806        buf.write(struct.pack("=xx2xIiI", picture, angle, num_stops))
807        buf.write(center.pack() if hasattr(center, "pack") else POINTFIX.synthetic(*center).pack())
808        buf.write(xcffib.pack_list(stops, "i"))
809        buf.write(xcffib.pack_list(colors, COLOR))
810        return self.send_request(36, buf, is_checked=is_checked)
811xcffib._add_ext(key, renderExtension, _events, _errors)
812