2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include "ecore_xcb_private.h"
9 * @defgroup Ecore_X_Shape_Group X Shape extension
11 * Functions that use the shape extension of the X server to change shape of given windows.
15 #ifdef ECORE_XCB_SHAPE
16 static int _shape_available = 0;
17 static xcb_shape_query_version_cookie_t _ecore_xcb_shape_init_cookie;
18 #endif /* ECORE_XCB_SHAPE */
21 /* To avoid round trips, the initialization is separated in 2
22 functions: _ecore_xcb_shape_init and
23 _ecore_xcb_shape_init_finalize. The first one gets the cookies and
24 the second one gets the replies. */
27 _ecore_x_shape_init(const xcb_query_extension_reply_t *reply)
29 #ifdef ECORE_XCB_SHAPE
30 if (reply && (reply->present))
31 _ecore_xcb_shape_init_cookie = xcb_shape_query_version_unchecked(_ecore_xcb_conn);
32 #endif /* ECORE_XCB_SHAPE */
36 _ecore_x_shape_init_finalize(void)
38 #ifdef ECORE_XCB_SHAPE
39 xcb_shape_query_version_reply_t *reply;
41 reply = xcb_shape_query_version_reply(_ecore_xcb_conn,
42 _ecore_xcb_shape_init_cookie,
49 #endif /* ECORE_XCB_SHAPE */
54 * Sets the shape of the given window to the given pixmap.
55 * @param dest_win The given window.
56 * @param source_mask A 2-bit depth pixmap that provides the new shape of the window.
58 * Sets the shape of the window @p dest_win to the pixmap @p source_mask.
59 * @ingroup Ecore_X_Shape_Group
62 ecore_x_window_shape_mask_set(Ecore_X_Window dest_win,
63 Ecore_X_Pixmap source_mask)
65 #ifdef ECORE_XCB_SHAPE
66 xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, source_mask);
67 #endif /* ECORE_XCB_SHAPE */
71 ecore_x_window_shape_window_set(Ecore_X_Window dest_win,
72 Ecore_X_Window shape_win)
74 #ifdef ECORE_XCB_SHAPE
75 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, shape_win);
76 #endif /* ECORE_XCB_SHAPE */
80 ecore_x_window_shape_window_set_xy(Ecore_X_Window dest_win,
81 Ecore_X_Window shape_win,
85 #ifdef ECORE_XCB_SHAPE
86 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, x, y, shape_win);
87 #endif /* ECORE_XCB_SHAPE */
92 * Sets the shape of the given window to a rectangle.
93 * @param dest_win The given window.
94 * @param x The X coordinate of the top left corner of the rectangle.
95 * @param y The Y coordinate of the top left corner of the rectangle.
96 * @param width The width of the rectangle.
97 * @param height The height of the rectangle.
99 * Sets the shape of the window @p dest_win to a rectangle defined by
100 * @p x, @p y, @p width and @p height.
101 * @ingroup Ecore_X_Shape_Group
104 ecore_x_window_shape_rectangle_set(Ecore_X_Window dest_win,
110 #ifdef ECORE_XCB_SHAPE
111 xcb_rectangle_t rect;
116 rect.height = height;
117 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 1, &rect);
118 #endif /* ECORE_XCB_SHAPE */
122 ecore_x_window_shape_rectangles_set(Ecore_X_Window dest_win,
123 Ecore_X_Rectangle *rects,
126 #ifdef ECORE_XCB_SHAPE
128 xcb_shape_rectangles(_ecore_xcb_conn,
129 XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
130 0, dest_win, 0, 0, num, (xcb_rectangle_t *)rects);
132 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 0, NULL);
133 #endif /* ECORE_XCB_SHAPE */
137 ecore_x_window_shape_window_add(Ecore_X_Window dest_win,
138 Ecore_X_Window shape_win)
140 #ifdef ECORE_XCB_SHAPE
141 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, shape_win);
142 #endif /* ECORE_XCB_SHAPE */
146 ecore_x_window_shape_window_add_xy(Ecore_X_Window dest_win,
147 Ecore_X_Window shape_win,
151 #ifdef ECORE_XCB_SHAPE
152 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, x, y, shape_win);
153 #endif /* ECORE_XCB_SHAPE */
157 ecore_x_window_shape_rectangle_add(Ecore_X_Window dest_win,
163 #ifdef ECORE_XCB_SHAPE
164 xcb_rectangle_t rect;
169 rect.height = height;
170 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 1, &rect);
171 #endif /* ECORE_XCB_SHAPE */
175 ecore_x_window_shape_rectangle_clip(Ecore_X_Window dest_win,
181 xcb_rectangle_t rect;
186 rect.height = height;
187 xcb_shape_rectangles(_ecore_xcb_conn,
188 XCB_SHAPE_SO_INTERSECT, XCB_SHAPE_SK_BOUNDING,
189 0, dest_win, 0, 0, 1, &rect);
193 ecore_x_window_shape_rectangles_add(Ecore_X_Window dest_win,
194 Ecore_X_Rectangle *rects,
197 #ifdef ECORE_XCB_SHAPE
199 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);
201 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 0, NULL);
202 #endif /* ECORE_XCB_SHAPE */
207 * Sends the ShapeGetRectangles request.
208 * @param window Requested window.
209 * @ingroup Ecore_X_Shape_Group
212 ecore_x_window_shape_rectangles_get_prefetch(Ecore_X_Window window)
214 #ifdef ECORE_XCB_SHAPE
215 xcb_shape_get_rectangles_cookie_t cookie;
217 cookie = xcb_shape_get_rectangles_unchecked(_ecore_xcb_conn, window, XCB_SHAPE_SK_BOUNDING);
218 _ecore_xcb_cookie_cache(cookie.sequence);
219 #endif /* ECORE_XCB_SHAPE */
224 * Gets the reply of the ShapeGetRectangles request sent by ecore_x_window_shape_rectangles_get_prefetch().
225 * @ingroup Ecore_X_Shape_Group
228 ecore_x_window_shape_rectangles_get_fetch(void)
230 #ifdef ECORE_XCB_SHAPE
231 xcb_shape_get_rectangles_cookie_t cookie;
232 xcb_shape_get_rectangles_reply_t *reply;
234 cookie.sequence = _ecore_xcb_cookie_get();
235 reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
236 _ecore_xcb_reply_cache(reply);
237 #endif /* ECORE_XCB_SHAPE */
243 * @param window Unused.
244 * @param num_ret To document.
245 * @return To document.
247 * To use this function, you must call before, and in order,
248 * ecore_x_window_shape_rectangles_get_prefetch(), which sends the ShapeGetRectangles request,
249 * then ecore_x_window_shape_rectangles_get_fetch(), which gets the reply.
250 * @ingroup Ecore_X_Shape_Group
252 EAPI Ecore_X_Rectangle *
253 ecore_x_window_shape_rectangles_get(Ecore_X_Window window __UNUSED__,
256 Ecore_X_Rectangle *rects = NULL;
258 #ifdef ECORE_XCB_SHAPE
259 xcb_shape_get_rectangles_reply_t *reply;
261 reply = _ecore_xcb_reply_get();
264 if (num_ret) *num_ret = 0;
268 num = reply->rectangles_len;
269 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
272 xcb_shape_get_rectangles_rectangles(reply),
273 num * sizeof (Ecore_X_Rectangle));
276 #endif /* ECORE_XCB_SHAPE */
278 if (num_ret) *num_ret = num;
284 ecore_x_window_shape_events_select(Ecore_X_Window dest_win,
287 #ifdef ECORE_XCB_SHAPE
288 xcb_shape_select_input(_ecore_xcb_conn, dest_win, on ? 1 : 0);
289 #endif /* ECORE_XCB_SHAPE */