1// x11-rs: Rust bindings for X11 libraries
2// The X11 libraries are available under the MIT license.
3// These bindings are public domain.
4
5use std::os::raw::{c_char, c_double, c_int, c_short, c_uint, c_ulong, c_ushort};
6
7use super::xlib::{Atom, Bool, Colormap, Cursor, Display, Pixmap, Region, Visual, XRectangle, XID};
8
9//
10// functions
11//
12
13x11_link! { Xrender, xrender, ["libXrender.so.1", "libXrender.so"], 44,
14 pub fn XRenderAddGlyphs (_7: *mut Display, _6: c_ulong, _5: *const c_ulong, _4: *const XGlyphInfo, _3: c_int, _2: *const c_char, _1: c_int) -> (),
15 pub fn XRenderAddTraps (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: *const XTrap, _1: c_int) -> (),
16 pub fn XRenderChangePicture (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *const XRenderPictureAttributes) -> (),
17 pub fn XRenderComposite (_13: *mut Display, _12: c_int, _11: c_ulong, _10: c_ulong, _9: c_ulong, _8: c_int, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (),
18 pub fn XRenderCompositeDoublePoly (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: *const XPointDouble, _2: c_int, _1: c_int) -> (),
19 pub fn XRenderCompositeString16 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_ushort, _1: c_int) -> (),
20 pub fn XRenderCompositeString32 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_uint, _1: c_int) -> (),
21 pub fn XRenderCompositeString8 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (),
22 pub fn XRenderCompositeText16 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt16, _1: c_int) -> (),
23 pub fn XRenderCompositeText32 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt32, _1: c_int) -> (),
24 pub fn XRenderCompositeText8 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt8, _1: c_int) -> (),
25 pub fn XRenderCompositeTrapezoids (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XTrapezoid, _1: c_int) -> (),
26 pub fn XRenderCompositeTriangles (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XTriangle, _1: c_int) -> (),
27 pub fn XRenderCompositeTriFan (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XPointFixed, _1: c_int) -> (),
28 pub fn XRenderCompositeTriStrip (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XPointFixed, _1: c_int) -> (),
29 pub fn XRenderCreateAnimCursor (_3: *mut Display, _2: c_int, _1: *mut XAnimCursor) -> c_ulong,
30 pub fn XRenderCreateConicalGradient (_5: *mut Display, _4: *const XConicalGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong,
31 pub fn XRenderCreateCursor (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> c_ulong,
32 pub fn XRenderCreateGlyphSet (_2: *mut Display, _1: *const XRenderPictFormat) -> c_ulong,
33 pub fn XRenderCreateLinearGradient (_5: *mut Display, _4: *const XLinearGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong,
34 pub fn XRenderCreatePicture (_5: *mut Display, _4: c_ulong, _3: *const XRenderPictFormat, _2: c_ulong, _1: *const XRenderPictureAttributes) -> c_ulong,
35 pub fn XRenderCreateRadialGradient (_5: *mut Display, _4: *const XRadialGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong,
36 pub fn XRenderCreateSolidFill (_2: *mut Display, _1: *const XRenderColor) -> c_ulong,
37 pub fn XRenderFillRectangle (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *const XRenderColor, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (),
38 pub fn XRenderFillRectangles (_6: *mut Display, _5: c_int, _4: c_ulong, _3: *const XRenderColor, _2: *const XRectangle, _1: c_int) -> (),
39 pub fn XRenderFindFormat (_4: *mut Display, _3: c_ulong, _2: *const XRenderPictFormat, _1: c_int) -> *mut XRenderPictFormat,
40 pub fn XRenderFindStandardFormat (_2: *mut Display, _1: c_int) -> *mut XRenderPictFormat,
41 pub fn XRenderFindVisualFormat (_2: *mut Display, _1: *const Visual) -> *mut XRenderPictFormat,
42 pub fn XRenderFreeGlyphs (_4: *mut Display, _3: c_ulong, _2: *const c_ulong, _1: c_int) -> (),
43 pub fn XRenderFreeGlyphSet (_2: *mut Display, _1: c_ulong) -> (),
44 pub fn XRenderFreePicture (_2: *mut Display, _1: c_ulong) -> (),
45 pub fn XRenderParseColor (_3: *mut Display, _2: *mut c_char, _1: *mut XRenderColor) -> c_int,
46 pub fn XRenderQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int,
47 pub fn XRenderQueryFilters (_2: *mut Display, _1: c_ulong) -> *mut XFilters,
48 pub fn XRenderQueryFormats (_1: *mut Display) -> c_int,
49 pub fn XRenderQueryPictIndexValues (_3: *mut Display, _2: *const XRenderPictFormat, _1: *mut c_int) -> *mut XIndexValue,
50 pub fn XRenderQuerySubpixelOrder (_2: *mut Display, _1: c_int) -> c_int,
51 pub fn XRenderQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int,
52 pub fn XRenderReferenceGlyphSet (_2: *mut Display, _1: c_ulong) -> c_ulong,
53 pub fn XRenderSetPictureClipRectangles (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: *const XRectangle, _1: c_int) -> (),
54 pub fn XRenderSetPictureClipRegion (_3: *mut Display, _2: c_ulong, _1: Region) -> (),
55 pub fn XRenderSetPictureFilter (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut c_int, _1: c_int) -> (),
56 pub fn XRenderSetPictureTransform (_3: *mut Display, _2: c_ulong, _1: *mut XTransform) -> (),
57 pub fn XRenderSetSubpixelOrder (_3: *mut Display, _2: c_int, _1: c_int) -> c_int,
58variadic:
59globals:
60}
61
62//
63// types
64//
65
66pub type Glyph = XID;
67pub type GlyphSet = XID;
68pub type PictFormat = XID;
69pub type Picture = XID;
70pub type XDouble = c_double;
71pub type XFixed = c_int;
72
73#[derive(Debug, Clone, Copy, PartialEq)]
74#[repr(C)]
75pub struct _XAnimCursor {
76 pub cursor: Cursor,
77 pub delay: c_ulong,
78}
79pub type XAnimCursor = _XAnimCursor;
80
81#[derive(Debug, Clone, Copy, PartialEq)]
82#[repr(C)]
83pub struct _XCircle {
84 pub x: XFixed,
85 pub y: XFixed,
86 pub radius: XFixed,
87}
88pub type XCircle = _XCircle;
89
90#[derive(Debug, Clone, Copy, PartialEq)]
91#[repr(C)]
92pub struct _XConicalGradient {
93 pub center: XPointFixed,
94 pub angle: XFixed,
95}
96pub type XConicalGradient = _XConicalGradient;
97
98#[derive(Debug, Clone, Copy, PartialEq)]
99#[repr(C)]
100pub struct _XFilters {
101 pub nfilter: c_int,
102 pub filter: *mut *mut c_char,
103 pub nalias: c_int,
104 pub alias: *mut c_short,
105}
106pub type XFilters = _XFilters;
107
108#[derive(Debug, Clone, Copy, PartialEq)]
109#[repr(C)]
110pub struct _XGlyphElt8 {
111 pub glyphset: GlyphSet,
112 pub chars: *mut c_char,
113 pub nchars: c_int,
114 pub xOff: c_int,
115 pub yOff: c_int,
116}
117pub type XGlyphElt8 = _XGlyphElt8;
118
119#[derive(Debug, Clone, Copy, PartialEq)]
120#[repr(C)]
121pub struct _XGlyphElt16 {
122 pub glyphset: GlyphSet,
123 pub chars: *mut c_ushort,
124 pub nchars: c_int,
125 pub xOff: c_int,
126 pub yOff: c_int,
127}
128pub type XGlyphElt16 = _XGlyphElt16;
129
130#[derive(Debug, Clone, Copy, PartialEq)]
131#[repr(C)]
132pub struct _XGlyphElt32 {
133 pub glyphset: GlyphSet,
134 pub chars: *mut c_uint,
135 pub nchars: c_int,
136 pub xOff: c_int,
137 pub yOff: c_int,
138}
139pub type XGlyphElt32 = _XGlyphElt32;
140
141#[derive(Debug, Clone, Copy, PartialEq)]
142#[repr(C)]
143pub struct _XGlyphInfo {
144 pub width: c_ushort,
145 pub height: c_ushort,
146 pub x: c_short,
147 pub y: c_short,
148 pub xOff: c_short,
149 pub yOff: c_short,
150}
151pub type XGlyphInfo = _XGlyphInfo;
152
153#[derive(Debug, Clone, Copy, PartialEq)]
154#[repr(C)]
155pub struct _XIndexValue {
156 pub pixel: c_ulong,
157 pub red: c_ushort,
158 pub green: c_ushort,
159 pub blue: c_ushort,
160 pub alpha: c_ushort,
161}
162pub type XIndexValue = _XIndexValue;
163
164#[derive(Debug, Clone, Copy, PartialEq)]
165#[repr(C)]
166pub struct _XLinearGradient {
167 pub p1: XPointFixed,
168 pub p2: XPointFixed,
169}
170pub type XLinearGradient = _XLinearGradient;
171
172#[derive(Debug, Clone, Copy, PartialEq)]
173#[repr(C)]
174pub struct _XLineFixed {
175 pub p1: XPointFixed,
176 pub p2: XPointFixed,
177}
178pub type XLineFixed = _XLineFixed;
179
180#[derive(Debug, Clone, Copy, PartialEq)]
181#[repr(C)]
182pub struct _XPointDouble {
183 pub x: XDouble,
184 pub y: XDouble,
185}
186pub type XPointDouble = _XPointDouble;
187
188#[derive(Debug, Clone, Copy, PartialEq)]
189#[repr(C)]
190pub struct _XPointFixed {
191 pub x: XFixed,
192 pub y: XFixed,
193}
194pub type XPointFixed = _XPointFixed;
195
196#[derive(Debug, Clone, Copy, PartialEq)]
197#[repr(C)]
198pub struct _XRadialGradient {
199 pub inner: XCircle,
200 pub outer: XCircle,
201}
202pub type XRadialGradient = _XRadialGradient;
203
204#[derive(Debug, Clone, Copy, PartialEq)]
205#[repr(C)]
206pub struct XRenderColor {
207 pub red: c_ushort,
208 pub green: c_ushort,
209 pub blue: c_ushort,
210 pub alpha: c_ushort,
211}
212
213#[derive(Debug, Clone, Copy, PartialEq)]
214#[repr(C)]
215pub struct XRenderDirectFormat {
216 pub red: c_short,
217 pub redMask: c_short,
218 pub green: c_short,
219 pub greenMask: c_short,
220 pub blue: c_short,
221 pub blueMask: c_short,
222 pub alpha: c_short,
223 pub alphaMask: c_short,
224}
225
226#[derive(Debug, Clone, Copy, PartialEq)]
227#[repr(C)]
228pub struct XRenderPictFormat {
229 pub id: PictFormat,
230 pub type_: c_int,
231 pub depth: c_int,
232 pub direct: XRenderDirectFormat,
233 pub colormap: Colormap,
234}
235
236#[derive(Debug, Clone, Copy, PartialEq)]
237#[repr(C)]
238pub struct _XRenderPictureAttributes {
239 pub repeat: c_int,
240 pub alpha_map: Picture,
241 pub alpha_x_origin: c_int,
242 pub alpha_y_origin: c_int,
243 pub clip_x_origin: c_int,
244 pub clip_y_origin: c_int,
245 pub clip_mask: Pixmap,
246 pub graphics_exposures: Bool,
247 pub subwindow_mode: c_int,
248 pub poly_edge: c_int,
249 pub poly_mode: c_int,
250 pub dither: Atom,
251 pub component_alpha: Bool,
252}
253pub type XRenderPictureAttributes = _XRenderPictureAttributes;
254
255#[derive(Debug, Clone, Copy, PartialEq)]
256#[repr(C)]
257pub struct _XSpanFix {
258 pub left: XFixed,
259 pub right: XFixed,
260 pub y: XFixed,
261}
262pub type XSpanFix = _XSpanFix;
263
264#[derive(Debug, Clone, Copy, PartialEq)]
265#[repr(C)]
266pub struct _XTrap {
267 pub top: XSpanFix,
268 pub bottom: XSpanFix,
269}
270pub type XTrap = _XTrap;
271
272#[derive(Debug, Clone, Copy, PartialEq)]
273#[repr(C)]
274pub struct _XTrapezoid {
275 pub top: XFixed,
276 pub bottom: XFixed,
277 pub left: XLineFixed,
278 pub right: XLineFixed,
279}
280pub type XTrapezoid = _XTrapezoid;
281
282#[derive(Debug, Clone, Copy, PartialEq)]
283#[repr(C)]
284pub struct _XTriangle {
285 pub p1: XPointFixed,
286 pub p2: XPointFixed,
287 pub p3: XPointFixed,
288}
289pub type XTriangle = _XTriangle;
290
291#[derive(Debug, Clone, Copy, PartialEq)]
292#[repr(C)]
293pub struct _XTransform {
294 pub matrix: [[XFixed; 3]; 3],
295}
296pub type XTransform = _XTransform;
297
298//
299// constants
300//
301
302// pict format mask
303pub const PictFormatID: c_ulong = 1 << 0;
304pub const PictFormatType: c_ulong = 1 << 1;
305pub const PictFormatDepth: c_ulong = 1 << 2;
306pub const PictFormatRed: c_ulong = 1 << 3;
307pub const PictFormatRedMask: c_ulong = 1 << 4;
308pub const PictFormatGreen: c_ulong = 1 << 5;
309pub const PictFormatGreenMask: c_ulong = 1 << 6;
310pub const PictFormatBlue: c_ulong = 1 << 7;
311pub const PictFormatBlueMask: c_ulong = 1 << 8;
312pub const PictFormatAlpha: c_ulong = 1 << 9;
313pub const PictFormatAlphaMask: c_ulong = 1 << 10;
314pub const PictFormatColormap: c_ulong = 1 << 11;
315
316// error codes
317pub const BadPictFormat: c_int = 0;
318pub const BadPicture: c_int = 1;
319pub const BadPictOp: c_int = 2;
320pub const BadGlyphSet: c_int = 3;
321pub const BadGlyph: c_int = 4;
322pub const RenderNumberErrors: c_int = BadGlyph + 1;
323
324// pict types
325pub const PictTypeIndexed: c_int = 0;
326pub const PictTypeDirect: c_int = 1;
327
328// ops
329pub const PictOpMinimum: c_int = 0;
330pub const PictOpClear: c_int = 0;
331pub const PictOpSrc: c_int = 1;
332pub const PictOpDst: c_int = 2;
333pub const PictOpOver: c_int = 3;
334pub const PictOpOverReverse: c_int = 4;
335pub const PictOpIn: c_int = 5;
336pub const PictOpInReverse: c_int = 6;
337pub const PictOpOut: c_int = 7;
338pub const PictOpOutReverse: c_int = 8;
339pub const PictOpAtop: c_int = 9;
340pub const PictOpAtopReverse: c_int = 10;
341pub const PictOpXor: c_int = 11;
342pub const PictOpAdd: c_int = 12;
343pub const PictOpSaturate: c_int = 13;
344pub const PictOpMaximum: c_int = 13;
345
346pub const PictOpDisjointMinimum: c_int = 0x10;
347pub const PictOpDisjointClear: c_int = 0x10;
348pub const PictOpDisjointSrc: c_int = 0x11;
349pub const PictOpDisjointDst: c_int = 0x12;
350pub const PictOpDisjointOver: c_int = 0x13;
351pub const PictOpDisjointOverReverse: c_int = 0x14;
352pub const PictOpDisjointIn: c_int = 0x15;
353pub const PictOpDisjointInReverse: c_int = 0x16;
354pub const PictOpDisjointOut: c_int = 0x17;
355pub const PictOpDisjointOutReverse: c_int = 0x18;
356pub const PictOpDisjointAtop: c_int = 0x19;
357pub const PictOpDisjointAtopReverse: c_int = 0x1a;
358pub const PictOpDisjointXor: c_int = 0x1b;
359pub const PictOpDisjointMaximum: c_int = 0x1b;
360
361pub const PictOpConjointMinimum: c_int = 0x20;
362pub const PictOpConjointClear: c_int = 0x20;
363pub const PictOpConjointSrc: c_int = 0x21;
364pub const PictOpConjointDst: c_int = 0x22;
365pub const PictOpConjointOver: c_int = 0x23;
366pub const PictOpConjointOverReverse: c_int = 0x24;
367pub const PictOpConjointIn: c_int = 0x25;
368pub const PictOpConjointInReverse: c_int = 0x26;
369pub const PictOpConjointOut: c_int = 0x27;
370pub const PictOpConjointOutReverse: c_int = 0x28;
371pub const PictOpConjointAtop: c_int = 0x29;
372pub const PictOpConjointAtopReverse: c_int = 0x2a;
373pub const PictOpConjointXor: c_int = 0x2b;
374pub const PictOpConjointMaximum: c_int = 0x2b;
375
376pub const PictOpBlendMinimum: c_int = 0x30;
377pub const PictOpMultiply: c_int = 0x30;
378pub const PictOpScreen: c_int = 0x31;
379pub const PictOpOverlay: c_int = 0x32;
380pub const PictOpDarken: c_int = 0x33;
381pub const PictOpLighten: c_int = 0x34;
382pub const PictOpColorDodge: c_int = 0x35;
383pub const PictOpColorBurn: c_int = 0x36;
384pub const PictOpHardLight: c_int = 0x37;
385pub const PictOpSoftLight: c_int = 0x38;
386pub const PictOpDifference: c_int = 0x39;
387pub const PictOpExclusion: c_int = 0x3a;
388pub const PictOpHSLHue: c_int = 0x3b;
389pub const PictOpHSLSaturation: c_int = 0x3c;
390pub const PictOpHSLColor: c_int = 0x3d;
391pub const PictOpHSLLuminosity: c_int = 0x3e;
392pub const PictOpBlendMaximum: c_int = 0x3e;
393
394pub const PictStandardARGB32: c_int = 0;
395pub const PictStandardRGB24: c_int = 0;
396pub const PictStandardA8: c_int = 2;
397pub const PictStandardA4: c_int = 3;
398pub const PictStandardA1: c_int = 4;
399
400// poly edge types
401pub const PolyEdgeSharp: c_int = 0;
402pub const PolyEdgeSmooth: c_int = 1;
403
404// poly modes
405pub const PolyModePrecise: c_int = 0;
406pub const PolyModeImprecise: c_int = 1;
407
408// picture attributes mask
409pub const CPRepeat: c_int = 1 << 0;
410pub const CPAlphaMap: c_int = 1 << 1;
411pub const CPAlphaXOrigin: c_int = 1 << 2;
412pub const CPAlphaYOrigin: c_int = 1 << 3;
413pub const CPClipXOrigin: c_int = 1 << 4;
414pub const CPClipYOrigin: c_int = 1 << 5;
415pub const CPClipMask: c_int = 1 << 6;
416pub const CPGraphicsExposure: c_int = 1 << 7;
417pub const CPSubwindowMode: c_int = 1 << 8;
418pub const CPPolyEdge: c_int = 1 << 9;
419pub const CPPolyMode: c_int = 1 << 10;
420pub const CPDither: c_int = 1 << 11;
421pub const CPComponentAlpha: c_int = 1 << 12;
422pub const CPLastBit: c_int = 12;
423
424// filter methods
425pub const FilterNearest: &str = "nearest";
426pub const FilterBilinear: &str = "bilinear";
427pub const FilterConvolution: &str = "convolution";
428pub const FilterFast: &str = "fast";
429pub const FilterGood: &str = "good";
430pub const FilterBest: &str = "best";
431
432// subpixel orders
433pub const SubPixelUnknown: c_int = 0;
434pub const SubPixelHorizontalRGB: c_int = 1;
435pub const SubPixelHorizontalBGR: c_int = 2;
436pub const SubPixelVerticalRGB: c_int = 3;
437pub const SubPixelVerticalBGR: c_int = 4;
438pub const SubPixelNone: c_int = 5;
439
440// repeat attributes
441pub const RepeatNone: c_int = 0;
442pub const RepeatNormal: c_int = 1;
443pub const RepeatPad: c_int = 2;
444pub const RepeatReflect: c_int = 3;
445