1 #include "ecore_xcb_private.h"
4 * @defgroup Ecore_X_Shape_Group X Shape extension
6 * Functions that use the shape extension of the X server to change shape of given windows.
10 static int _shape_available = 0;
11 static xcb_shape_query_version_cookie_t _ecore_xcb_shape_init_cookie;
12 #endif /* ECORE_XCB_SHAPE */
14 /* To avoid round trips, the initialization is separated in 2
15 functions: _ecore_xcb_shape_init and
16 _ecore_xcb_shape_init_finalize. The first one gets the cookies and
17 the second one gets the replies. */
20 _ecore_x_shape_init(const xcb_query_extension_reply_t *reply)
22 #ifdef ECORE_XCB_SHAPE
23 if (reply && (reply->present))
24 _ecore_xcb_shape_init_cookie = xcb_shape_query_version_unchecked(_ecore_xcb_conn);
26 #endif /* ECORE_XCB_SHAPE */
27 } /* _ecore_x_shape_init */
30 _ecore_x_shape_init_finalize(void)
32 #ifdef ECORE_XCB_SHAPE
33 xcb_shape_query_version_reply_t *reply;
35 reply = xcb_shape_query_version_reply(_ecore_xcb_conn,
36 _ecore_xcb_shape_init_cookie,
44 #endif /* ECORE_XCB_SHAPE */
45 } /* _ecore_x_shape_init_finalize */
48 * Sets the shape of the given window to the given pixmap.
49 * @param dest_win The given window.
50 * @param source_mask A 2-bit depth pixmap that provides the new shape of the window.
52 * Sets the shape of the window @p dest_win to the pixmap @p source_mask.
53 * @ingroup Ecore_X_Shape_Group
56 ecore_x_window_shape_mask_set(Ecore_X_Window dest_win,
57 Ecore_X_Pixmap source_mask)
59 #ifdef ECORE_XCB_SHAPE
60 xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, source_mask);
61 #endif /* ECORE_XCB_SHAPE */
62 } /* ecore_x_window_shape_mask_set */
65 ecore_x_window_shape_window_set(Ecore_X_Window dest_win,
66 Ecore_X_Window shape_win)
68 #ifdef ECORE_XCB_SHAPE
69 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, shape_win);
70 #endif /* ECORE_XCB_SHAPE */
71 } /* ecore_x_window_shape_window_set */
74 ecore_x_window_shape_window_set_xy(Ecore_X_Window dest_win,
75 Ecore_X_Window shape_win,
79 #ifdef ECORE_XCB_SHAPE
80 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, x, y, shape_win);
81 #endif /* ECORE_XCB_SHAPE */
82 } /* ecore_x_window_shape_window_set_xy */
85 * Sets the shape of the given window to a rectangle.
86 * @param dest_win The given window.
87 * @param x The X coordinate of the top left corner of the rectangle.
88 * @param y The Y coordinate of the top left corner of the rectangle.
89 * @param width The width of the rectangle.
90 * @param height The height of the rectangle.
92 * Sets the shape of the window @p dest_win to a rectangle defined by
93 * @p x, @p y, @p width and @p height.
94 * @ingroup Ecore_X_Shape_Group
97 ecore_x_window_shape_rectangle_set(Ecore_X_Window dest_win,
103 #ifdef ECORE_XCB_SHAPE
104 xcb_rectangle_t rect;
109 rect.height = height;
110 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 1, &rect);
111 #endif /* ECORE_XCB_SHAPE */
112 } /* ecore_x_window_shape_rectangle_set */
115 ecore_x_window_shape_rectangles_set(Ecore_X_Window dest_win,
116 Ecore_X_Rectangle *rects,
119 #ifdef ECORE_XCB_SHAPE
121 xcb_shape_rectangles(_ecore_xcb_conn,
122 XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
123 0, dest_win, 0, 0, num, (xcb_rectangle_t *)rects);
125 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 0, NULL);
127 #endif /* ECORE_XCB_SHAPE */
128 } /* ecore_x_window_shape_rectangles_set */
131 ecore_x_window_shape_window_add(Ecore_X_Window dest_win,
132 Ecore_X_Window shape_win)
134 #ifdef ECORE_XCB_SHAPE
135 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, shape_win);
136 #endif /* ECORE_XCB_SHAPE */
137 } /* ecore_x_window_shape_window_add */
140 ecore_x_window_shape_window_add_xy(Ecore_X_Window dest_win,
141 Ecore_X_Window shape_win,
145 #ifdef ECORE_XCB_SHAPE
146 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, x, y, shape_win);
147 #endif /* ECORE_XCB_SHAPE */
148 } /* ecore_x_window_shape_window_add_xy */
151 ecore_x_window_shape_rectangle_add(Ecore_X_Window dest_win,
157 #ifdef ECORE_XCB_SHAPE
158 xcb_rectangle_t rect;
163 rect.height = height;
164 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 1, &rect);
165 #endif /* ECORE_XCB_SHAPE */
166 } /* ecore_x_window_shape_rectangle_add */
169 ecore_x_window_shape_rectangle_clip(Ecore_X_Window dest_win,
175 #ifdef ECORE_XCB_SHAPE
176 xcb_rectangle_t rect;
181 rect.height = height;
182 xcb_shape_rectangles(_ecore_xcb_conn,
183 XCB_SHAPE_SO_INTERSECT, XCB_SHAPE_SK_BOUNDING,
184 0, dest_win, 0, 0, 1, &rect);
185 #endif /* ECORE_XCB_SHAPE */
186 } /* ecore_x_window_shape_rectangle_clip */
189 ecore_x_window_shape_rectangles_add(Ecore_X_Window dest_win,
190 Ecore_X_Rectangle *rects,
193 #ifdef ECORE_XCB_SHAPE
195 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, num, (const xcb_rectangle_t *)rects);
197 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 0, NULL);
199 #endif /* ECORE_XCB_SHAPE */
200 } /* ecore_x_window_shape_rectangles_add */
203 * Sends the ShapeGetRectangles request.
204 * @param window Requested window.
205 * @ingroup Ecore_X_Shape_Group
208 ecore_x_window_shape_rectangles_get_prefetch(Ecore_X_Window window)
210 #ifdef ECORE_XCB_SHAPE
211 xcb_shape_get_rectangles_cookie_t cookie;
213 cookie = xcb_shape_get_rectangles_unchecked(_ecore_xcb_conn, window, XCB_SHAPE_SK_BOUNDING);
214 _ecore_xcb_cookie_cache(cookie.sequence);
215 #endif /* ECORE_XCB_SHAPE */
216 } /* ecore_x_window_shape_rectangles_get_prefetch */
219 * Gets the reply of the ShapeGetRectangles request sent by ecore_x_window_shape_rectangles_get_prefetch().
220 * @ingroup Ecore_X_Shape_Group
223 ecore_x_window_shape_rectangles_get_fetch(void)
225 #ifdef ECORE_XCB_SHAPE
226 xcb_shape_get_rectangles_cookie_t cookie;
227 xcb_shape_get_rectangles_reply_t *reply;
229 cookie.sequence = _ecore_xcb_cookie_get();
230 reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
231 _ecore_xcb_reply_cache(reply);
232 #endif /* ECORE_XCB_SHAPE */
233 } /* ecore_x_window_shape_rectangles_get_fetch */
237 * @param window Unused.
238 * @param num_ret To document.
239 * @return To document.
241 * To use this function, you must call before, and in order,
242 * ecore_x_window_shape_rectangles_get_prefetch(), which sends the ShapeGetRectangles request,
243 * then ecore_x_window_shape_rectangles_get_fetch(), which gets the reply.
244 * @ingroup Ecore_X_Shape_Group
246 EAPI Ecore_X_Rectangle *
247 ecore_x_window_shape_rectangles_get(Ecore_X_Window window __UNUSED__,
250 Ecore_X_Rectangle *rects = NULL;
252 #ifdef ECORE_XCB_SHAPE
253 xcb_shape_get_rectangles_reply_t *reply;
255 reply = _ecore_xcb_reply_get();
264 num = reply->rectangles_len;
265 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
268 xcb_shape_get_rectangles_rectangles(reply),
269 num * sizeof (Ecore_X_Rectangle));
273 #endif /* ECORE_XCB_SHAPE */
279 } /* ecore_x_window_shape_rectangles_get */
282 ecore_x_window_shape_events_select(Ecore_X_Window dest_win,
285 #ifdef ECORE_XCB_SHAPE
286 xcb_shape_select_input(_ecore_xcb_conn, dest_win, on ? 1 : 0);
287 #endif /* ECORE_XCB_SHAPE */
288 } /* ecore_x_window_shape_events_select */