switched to GPLv3 ONLY, because i don't trust FSF anymore
[amper.git] / egfx / xshape.d
blob3f847c62b52b93e1097062c138843c948bd4cc43
1 module egfx.xshape;
3 import arsd.simpledisplay;
6 // ////////////////////////////////////////////////////////////////////////// //
7 public extern(C) nothrow @nogc {
9 import core.stdc.config : c_long, c_ulong;
11 struct XBoxRec {
12 short x1, x2, y1, y2;
14 alias XBox = XBoxRec*;
17 // clip region
18 struct XRegionRec {
19 c_long size;
20 c_long numRects;
21 XBox rects;
22 XBoxRec extents;
24 alias XRegion = XRegionRec*;
27 enum ShapeSet = 0;
28 enum ShapeUnion = 1;
29 enum ShapeIntersect = 2;
30 enum ShapeSubtract = 3;
31 enum ShapeInvert = 4;
33 enum ShapeBounding = 0;
34 enum ShapeClip = 1;
35 enum ShapeInput = 2;
37 enum ShapeNotifyMask = 1U<<0;
38 enum ShapeNotify = 0;
40 enum ShapeNumberEvents = ShapeNotify+1;
42 struct XShapeEvent {
43 int type; /* of event */
44 c_ulong serial; /* # of last request processed by server */
45 Bool send_event; /* true if this came frome a SendEvent request */
46 Display* display; /* Display the event was read from */
47 Window window; /* window of event */
48 int kind; /* ShapeBounding or ShapeClip */
49 int x, y; /* extents of new region */
50 uint width, height;
51 Time time; /* server timestamp when region changed */
52 Bool shaped; /* true if the region exists */
56 Bool XShapeQueryExtension (
57 Display* display,
58 int* event_base,
59 int* error_base
62 Status XShapeQueryVersion (
63 Display* display,
64 int* major_version,
65 int* minor_version
68 void XShapeCombineRegion (
69 Display* display,
70 Window dest,
71 int dest_kind,
72 int x_off,
73 int y_off,
74 XRegion region,
75 int op
78 void XShapeCombineRectangles (
79 Display* display,
80 Window dest,
81 int dest_kind,
82 int x_off,
83 int y_off,
84 XRectangle* rectangles,
85 int n_rects,
86 int op,
87 int ordering
90 void XShapeCombineMask (
91 Display* display,
92 Window dest,
93 int dest_kind,
94 int x_off,
95 int y_off,
96 Pixmap src,
97 int op
100 void XShapeCombineShape (
101 Display* display,
102 Window dest,
103 int dest_kind,
104 int x_off,
105 int y_off,
106 Window src,
107 int src_kind,
108 int op
111 void XShapeOffsetShape (
112 Display* display,
113 Window dest,
114 int dest_kind,
115 int x_off,
116 int y_off
119 Status XShapeQueryExtents (
120 Display* display,
121 Window window,
122 Bool* bounding_shaped,
123 int* x_bounding,
124 int* y_bounding,
125 uint* w_bounding,
126 uint* h_bounding,
127 Bool* clip_shaped,
128 int* x_clip,
129 int* y_clip,
130 uint* w_clip,
131 uint* h_clip
134 void XShapeSelectInput (
135 Display* display,
136 Window window,
137 c_ulong mask
140 c_ulong XShapeInputSelected (
141 Display* display,
142 Window window
145 XRectangle *XShapeGetRectangles (
146 Display* display,
147 Window window,
148 int kind,
149 int* count,
150 int* ordering
153 // ////////////////////////////////////////////////////////////////////////// //
154 //struct XRegionRec {}
155 //alias XRegion = XRegionRec*;
157 enum {
158 EvenOddRule = 0,
159 WindingRule = 1,
163 XRegion XCreateRegion ();
164 int XDestroyRegion (XRegion r);
165 XRegion XPolygonRegion (XPoint* points, int n, int fill_rule);
166 int XUnionRegion (XRegion sra, XRegion srb, XRegion dr_return);
171 // ////////////////////////////////////////////////////////////////////////// //
172 // <0: ooops
173 public int shapeEvent () {
174 __gshared static int event = -666;
175 if (event == -666) {
176 int dummy;
177 if (!XShapeQueryExtension(XDisplayConnection.get(), &event, &dummy)) event = -1;
179 return event;
185 XRectangle[2] rects;
186 rects[0] = XRectangle(0, 0, 60, 20);
187 rects[1] = XRectangle(100, 100, 60, 20);
188 XShapeCombineRectangles(win.impl.display, win.impl.window, ShapeBounding, 0, 0, rects.ptr, rects.length, ShapeIntersect, 0);
189 //XShapeCombineRectangles(win.impl.display, win.impl.window, ShapeClip, 0, 0, rects.ptr, rects.length, ShapeIntersect, 0);