aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c364
1 files changed, 364 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c
new file mode 100644
index 0000000..e81af13
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c
@@ -0,0 +1,364 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6
7#include "ecore_x_private.h"
8#include "Ecore_X.h"
9
10static int _fixes_available;
11#ifdef ECORE_XFIXES
12static int _fixes_major, _fixes_minor;
13#endif /* ifdef ECORE_XFIXES */
14
15void
16_ecore_x_fixes_init(void)
17{
18#ifdef ECORE_XFIXES
19 _fixes_major = 3;
20 _fixes_minor = 0;
21
22 LOGFN(__FILE__, __LINE__, __FUNCTION__);
23 if (XFixesQueryVersion(_ecore_x_disp, &_fixes_major, &_fixes_minor))
24 {
25 _fixes_available = 1;
26
27 ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = ecore_event_type_new();
28 }
29 else
30 _fixes_available = 0;
31
32#else /* ifdef ECORE_XFIXES */
33 _fixes_available = 0;
34#endif /* ifdef ECORE_XFIXES */
35} /* _ecore_x_fixes_init */
36
37#ifdef ECORE_XFIXES
38/* I don't know what to call this function. */
39static XRectangle *
40_ecore_x_rectangle_ecore_to_x(Ecore_X_Rectangle *rects,
41 int num)
42{
43 XRectangle *xrect;
44 int i;
45
46 if (num == 0)
47 return NULL;
48
49 xrect = malloc(sizeof(XRectangle) * num);
50 if (!xrect)
51 return NULL;
52
53 for (i = 0; i < num; i++)
54 {
55 xrect[i].x = rects[i].x;
56 xrect[i].y = rects[i].y;
57 xrect[i].width = rects[i].width;
58 xrect[i].height = rects[i].height;
59 }
60 return xrect;
61} /* _ecore_x_rectangle_ecore_to_x */
62
63static Ecore_X_Rectangle *
64_ecore_x_rectangle_x_to_ecore(XRectangle *xrect,
65 int num)
66{
67 Ecore_X_Rectangle *rects;
68 int i;
69
70 if (num == 0)
71 return NULL;
72
73 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
74 if (!rects)
75 return NULL;
76
77 for (i = 0; i < num; i++)
78 {
79 rects[i].x = xrect[i].x;
80 rects[i].y = xrect[i].y;
81 rects[i].width = xrect[i].width;
82 rects[i].height = xrect[i].height;
83 }
84 return rects;
85} /* _ecore_x_rectangle_x_to_ecore */
86
87#endif /* ifdef ECORE_XFIXES */
88
89EAPI Eina_Bool
90ecore_x_fixes_selection_notification_request(Ecore_X_Atom selection)
91{
92#ifdef ECORE_XFIXES
93 if (_fixes_available)
94 {
95 XFixesSelectSelectionInput (_ecore_x_disp,
96 DefaultRootWindow(_ecore_x_disp),
97 selection,
98 XFixesSetSelectionOwnerNotifyMask |
99 XFixesSelectionWindowDestroyNotifyMask |
100 XFixesSelectionClientCloseNotifyMask);
101 return EINA_TRUE;
102 }
103#endif
104 return EINA_FALSE;
105}
106
107EAPI Ecore_X_Region
108ecore_x_region_new(Ecore_X_Rectangle *rects,
109 int num)
110{
111#ifdef ECORE_XFIXES
112 Ecore_X_Region region;
113 XRectangle *xrect;
114
115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
116 xrect = _ecore_x_rectangle_ecore_to_x(rects, num);
117 region = XFixesCreateRegion(_ecore_x_disp, xrect, num);
118 free(xrect);
119 return region;
120#else /* ifdef ECORE_XFIXES */
121 return 0;
122#endif /* ifdef ECORE_XFIXES */
123} /* ecore_x_region_new */
124
125EAPI Ecore_X_Region
126ecore_x_region_new_from_bitmap(Ecore_X_Pixmap bitmap)
127{
128#ifdef ECORE_XFIXES
129 Ecore_X_Region region;
130
131 LOGFN(__FILE__, __LINE__, __FUNCTION__);
132 region = XFixesCreateRegionFromBitmap(_ecore_x_disp, bitmap);
133 return region;
134#else /* ifdef ECORE_XFIXES */
135 return 0;
136#endif /* ifdef ECORE_XFIXES */
137} /* ecore_x_region_new_from_bitmap */
138
139EAPI Ecore_X_Region
140ecore_x_region_new_from_window(Ecore_X_Window win,
141 Ecore_X_Region_Type type)
142{
143#ifdef ECORE_XFIXES
144 Ecore_X_Region region;
145
146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
147 region = XFixesCreateRegionFromWindow(_ecore_x_disp, win, type);
148 return region;
149#else /* ifdef ECORE_XFIXES */
150 return 0;
151#endif /* ifdef ECORE_XFIXES */
152} /* ecore_x_region_new_from_window */
153
154EAPI Ecore_X_Region
155ecore_x_region_new_from_gc(Ecore_X_GC gc)
156{
157#ifdef ECORE_XFIXES
158 Ecore_X_Region region;
159
160 LOGFN(__FILE__, __LINE__, __FUNCTION__);
161 region = XFixesCreateRegionFromGC(_ecore_x_disp, gc);
162 return region;
163#else /* ifdef ECORE_XFIXES */
164 return 0;
165#endif /* ifdef ECORE_XFIXES */
166} /* ecore_x_region_new_from_gc */
167
168EAPI Ecore_X_Region
169ecore_x_region_new_from_picture(Ecore_X_Picture picture)
170{
171#ifdef ECORE_XFIXES
172 Ecore_X_Region region;
173
174 LOGFN(__FILE__, __LINE__, __FUNCTION__);
175 region = XFixesCreateRegionFromPicture(_ecore_x_disp, picture);
176 return region;
177#else /* ifdef ECORE_XFIXES */
178 return 0;
179#endif /* ifdef ECORE_XFIXES */
180} /* ecore_x_region_new_from_picture */
181
182EAPI void
183ecore_x_region_free(Ecore_X_Region region)
184{
185#ifdef ECORE_XFIXES
186 LOGFN(__FILE__, __LINE__, __FUNCTION__);
187 XFixesDestroyRegion(_ecore_x_disp, region);
188#endif /* ifdef ECORE_XFIXES */
189} /* ecore_x_region_free */
190
191EAPI void
192ecore_x_region_set(Ecore_X_Region region,
193 Ecore_X_Rectangle *rects,
194 int num)
195{
196#ifdef ECORE_XFIXES
197 XRectangle *xrect = _ecore_x_rectangle_ecore_to_x(rects, num);
198 LOGFN(__FILE__, __LINE__, __FUNCTION__);
199 XFixesSetRegion(_ecore_x_disp, region, xrect, num);
200#endif /* ifdef ECORE_XFIXES */
201} /* ecore_x_region_set */
202
203EAPI void
204ecore_x_region_copy(Ecore_X_Region dest,
205 Ecore_X_Region source)
206{
207#ifdef ECORE_XFIXES
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 XFixesCopyRegion(_ecore_x_disp, dest, source);
210#endif /* ifdef ECORE_XFIXES */
211} /* ecore_x_region_copy */
212
213EAPI void
214ecore_x_region_combine(Ecore_X_Region dest,
215 Ecore_X_Region source1,
216 Ecore_X_Region source2)
217{
218#ifdef ECORE_XFIXES
219 LOGFN(__FILE__, __LINE__, __FUNCTION__);
220 XFixesUnionRegion(_ecore_x_disp, dest, source1, source2);
221#endif /* ifdef ECORE_XFIXES */
222} /* ecore_x_region_combine */
223
224EAPI void
225ecore_x_region_intersect(Ecore_X_Region dest,
226 Ecore_X_Region source1,
227 Ecore_X_Region source2)
228{
229#ifdef ECORE_XFIXES
230 LOGFN(__FILE__, __LINE__, __FUNCTION__);
231 XFixesIntersectRegion(_ecore_x_disp, dest, source1, source2);
232#endif /* ifdef ECORE_XFIXES */
233} /* ecore_x_region_intersect */
234
235EAPI void
236ecore_x_region_subtract(Ecore_X_Region dest,
237 Ecore_X_Region source1,
238 Ecore_X_Region source2)
239{
240#ifdef ECORE_XFIXES
241 LOGFN(__FILE__, __LINE__, __FUNCTION__);
242 XFixesSubtractRegion(_ecore_x_disp, dest, source1, source2);
243#endif /* ifdef ECORE_XFIXES */
244} /* ecore_x_region_subtract */
245
246EAPI void
247ecore_x_region_invert(Ecore_X_Region dest,
248 Ecore_X_Rectangle *bounds,
249 Ecore_X_Region source)
250{
251#ifdef ECORE_XFIXES
252 XRectangle *xbound;
253 int num = 0;
254
255 LOGFN(__FILE__, __LINE__, __FUNCTION__);
256 while (bounds + num) num++;
257 xbound = _ecore_x_rectangle_ecore_to_x(bounds, num);
258
259 XFixesInvertRegion(_ecore_x_disp, dest, xbound, source);
260#endif /* ifdef ECORE_XFIXES */
261} /* ecore_x_region_invert */
262
263EAPI void
264ecore_x_region_translate(Ecore_X_Region region,
265 int dx,
266 int dy)
267{
268#ifdef ECORE_XFIXES
269 LOGFN(__FILE__, __LINE__, __FUNCTION__);
270 XFixesTranslateRegion(_ecore_x_disp, region, dx, dy);
271#endif /* ifdef ECORE_XFIXES */
272} /* ecore_x_region_translate */
273
274EAPI void
275ecore_x_region_extents(Ecore_X_Region dest,
276 Ecore_X_Region source)
277{
278#ifdef ECORE_XFIXES
279 LOGFN(__FILE__, __LINE__, __FUNCTION__);
280 XFixesRegionExtents(_ecore_x_disp, dest, source);
281#endif /* ifdef ECORE_XFIXES */
282} /* ecore_x_region_extents */
283
284EAPI Ecore_X_Rectangle *
285ecore_x_region_fetch(Ecore_X_Region region,
286 int *num,
287 Ecore_X_Rectangle *bounds){
288#ifdef ECORE_XFIXES
289 Ecore_X_Rectangle *rects;
290 XRectangle *xrect, xbound;
291
292 LOGFN(__FILE__, __LINE__, __FUNCTION__);
293 xrect = XFixesFetchRegionAndBounds(_ecore_x_disp, region, num, &xbound);
294 rects = _ecore_x_rectangle_x_to_ecore(xrect, *num);
295 (*bounds).x = xbound.x;
296 (*bounds).y = xbound.y;
297 (*bounds).width = xbound.width;
298 (*bounds).height = xbound.height;
299 return rects;
300#else /* ifdef ECORE_XFIXES */
301 return NULL;
302#endif /* ifdef ECORE_XFIXES */
303} /* ecore_x_region_fetch */
304
305EAPI void
306ecore_x_region_expand(Ecore_X_Region dest,
307 Ecore_X_Region source,
308 unsigned int left,
309 unsigned int right,
310 unsigned int top,
311 unsigned int bottom)
312{
313#ifdef ECORE_XFIXES
314 LOGFN(__FILE__, __LINE__, __FUNCTION__);
315 XFixesExpandRegion(_ecore_x_disp, dest, source, left, right, top, bottom);
316#endif /* ifdef ECORE_XFIXES */
317} /* ecore_x_region_expand */
318
319EAPI void
320ecore_x_region_gc_clip_set(Ecore_X_Region region,
321 Ecore_X_GC gc,
322 int x_origin,
323 int y_origin)
324{
325#ifdef ECORE_XFIXES
326 LOGFN(__FILE__, __LINE__, __FUNCTION__);
327 XFixesSetGCClipRegion(_ecore_x_disp, gc, x_origin, y_origin, region);
328#endif /* ifdef ECORE_XFIXES */
329} /* ecore_x_region_gc_clip_set */
330
331EAPI void
332ecore_x_region_window_shape_set(Ecore_X_Region region,
333 Ecore_X_Window win,
334 Ecore_X_Shape_Type type,
335 int x_offset,
336 int y_offset)
337{
338#ifdef ECORE_XFIXES
339 LOGFN(__FILE__, __LINE__, __FUNCTION__);
340 XFixesSetWindowShapeRegion(_ecore_x_disp,
341 win,
342 type,
343 x_offset,
344 y_offset,
345 region);
346#endif /* ifdef ECORE_XFIXES */
347} /* ecore_x_region_window_shape_set */
348
349EAPI void
350ecore_x_region_picture_clip_set(Ecore_X_Region region,
351 Ecore_X_Picture picture,
352 int x_origin,
353 int y_origin)
354{
355#ifdef ECORE_XFIXES
356 LOGFN(__FILE__, __LINE__, __FUNCTION__);
357 XFixesSetPictureClipRegion(_ecore_x_disp,
358 picture,
359 x_origin,
360 y_origin,
361 region);
362#endif /* ifdef ECORE_XFIXES */
363} /* ecore_x_region_picture_clip_set */
364