remove xcb support in ecore_x and evas engines as per mailing list
[platform/upstream/efl.git] / src / lib / ecore_x / ecore_x_region.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif /* ifdef HAVE_CONFIG_H */
4
5 #include "ecore_x_private.h"
6
7 /*
8  * [x] XCreateRegion
9  * [ ] XPolygonRegion
10  * [x] XSetRegion
11  * [x] XDestroyRegion
12  *
13  * [x] XOffsetRegion
14  * [ ] XShrinkRegion
15  *
16  * [ ] XClipBox
17  * [x] XIntersectRegion
18  * [x] XUnionRegion
19  * [x] XUnionRectWithRegion
20  * [x] XSubtractRegion
21  * [ ] XXorRegion
22  *
23  * [x] XEmptyRegion
24  * [x] XEqualRegion
25  *
26  * [x] XPointInRegion
27  * [x] XRectInRegion
28  */
29
30 EAPI Ecore_X_XRegion *
31 ecore_x_xregion_new()
32 {
33    LOGFN(__FILE__, __LINE__, __FUNCTION__);
34    return (Ecore_X_XRegion *)XCreateRegion();
35 }
36
37 EAPI void
38 ecore_x_xregion_free(Ecore_X_XRegion *region)
39 {
40    LOGFN(__FILE__, __LINE__, __FUNCTION__);
41    if (!region)
42      return;
43
44    XDestroyRegion((Region)region);
45 }
46
47 EAPI Eina_Bool
48 ecore_x_xregion_set(Ecore_X_XRegion *region,
49                     Ecore_X_GC gc)
50 {
51    Eina_Bool ret;
52    LOGFN(__FILE__, __LINE__, __FUNCTION__);
53    ret = !!XSetRegion(_ecore_x_disp, gc, (Region)region);
54    if (_ecore_xlib_sync) ecore_x_sync();
55    return ret;
56 }
57
58 EAPI void
59 ecore_x_xregion_translate(Ecore_X_XRegion *region,
60                           int x,
61                           int y)
62 {
63    LOGFN(__FILE__, __LINE__, __FUNCTION__);
64    if (!region)
65      return;
66
67    /* return value not used */
68    XOffsetRegion((Region)region, x, y);
69 }
70
71 EAPI Eina_Bool
72 ecore_x_xregion_intersect(Ecore_X_XRegion *dst,
73                           Ecore_X_XRegion *r1,
74                           Ecore_X_XRegion *r2)
75 {
76    LOGFN(__FILE__, __LINE__, __FUNCTION__);
77    return XIntersectRegion((Region)r1, (Region)r2, (Region)dst) ? EINA_TRUE : EINA_FALSE;
78 }
79
80 EAPI Eina_Bool
81 ecore_x_xregion_union(Ecore_X_XRegion *dst,
82                       Ecore_X_XRegion *r1,
83                       Ecore_X_XRegion *r2)
84 {
85    LOGFN(__FILE__, __LINE__, __FUNCTION__);
86    return XUnionRegion((Region)r1, (Region)r2, (Region)dst) ? EINA_TRUE : EINA_FALSE;
87 }
88
89 EAPI Eina_Bool
90 ecore_x_xregion_union_rect(Ecore_X_XRegion *dst,
91                            Ecore_X_XRegion *src,
92                            Ecore_X_Rectangle *rect)
93 {
94    XRectangle xr;
95
96    LOGFN(__FILE__, __LINE__, __FUNCTION__);
97    xr.x = rect->x;
98    xr.y = rect->y;
99    xr.width = rect->width;
100    xr.height = rect->height;
101
102    return XUnionRectWithRegion(&xr, (Region)src, (Region)dst) ? EINA_TRUE : EINA_FALSE;
103 }
104
105 EAPI Eina_Bool
106 ecore_x_xregion_subtract(Ecore_X_XRegion *dst,
107                          Ecore_X_XRegion *rm,
108                          Ecore_X_XRegion *rs)
109 {
110    LOGFN(__FILE__, __LINE__, __FUNCTION__);
111    return XSubtractRegion((Region)rm, (Region)rs, (Region)dst) ? EINA_TRUE : EINA_FALSE;
112 }
113
114 EAPI Eina_Bool
115 ecore_x_xregion_is_empty(Ecore_X_XRegion *region)
116 {
117    if (!region)
118      return EINA_TRUE;
119
120    LOGFN(__FILE__, __LINE__, __FUNCTION__);
121    return XEmptyRegion((Region)region) ? EINA_TRUE : EINA_FALSE;
122 }
123
124 EAPI Eina_Bool
125 ecore_x_xregion_is_equal(Ecore_X_XRegion *r1,
126                          Ecore_X_XRegion *r2)
127 {
128    if (!r1 || !r2)
129      return EINA_FALSE;
130
131    LOGFN(__FILE__, __LINE__, __FUNCTION__);
132    return XEqualRegion((Region)r1, (Region)r1) ? EINA_TRUE : EINA_FALSE;
133 }
134
135 EAPI Eina_Bool
136 ecore_x_xregion_point_contain(Ecore_X_XRegion *region,
137                               int x,
138                               int y)
139 {
140    if (!region)
141      return EINA_FALSE;
142
143    LOGFN(__FILE__, __LINE__, __FUNCTION__);
144    return XPointInRegion((Region)region, x, y) ? EINA_TRUE : EINA_FALSE;
145 }
146
147 EAPI Eina_Bool
148 ecore_x_xregion_rect_contain(Ecore_X_XRegion *region,
149                              Ecore_X_Rectangle *rect)
150 {
151    if (!region || !rect)
152      return EINA_FALSE;
153
154    LOGFN(__FILE__, __LINE__, __FUNCTION__);
155    return XRectInRegion((Region)region,
156                         rect->x,
157                         rect->y,
158                         rect->width,
159                         rect->height) ? EINA_TRUE : EINA_FALSE;
160 }
161