1 #include "ecore_xcb_private.h"
3 # include <xcb/shape.h>
7 * @defgroup Ecore_X_Window_Shape X Window Shape Functions
8 * @ingroup Ecore_X_Group
10 * These functions use the shape extension of the X server to change
11 * shape of given windows.
15 * Sets the input shape of the given window to that given by the pixmap @p mask.
16 * @param win The given window.
17 * @param mask A 1-bit depth pixmap that provides the new input shape of the
19 * @ingroup Ecore_X_Window_Shape
22 ecore_x_window_shape_input_mask_set(Ecore_X_Window win,
25 LOGFN(__FILE__, __LINE__, __FUNCTION__);
28 #ifdef ECORE_XCB_SHAPE
29 xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
40 * Sets the shape of the given window to that given by the pixmap @p mask.
41 * @param win The given window.
42 * @param mask A 2-bit depth pixmap that provides the new shape of the
44 * @ingroup Ecore_X_Window_Shape
47 ecore_x_window_shape_mask_set(Ecore_X_Window win,
50 LOGFN(__FILE__, __LINE__, __FUNCTION__);
53 #ifdef ECORE_XCB_SHAPE
54 xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
65 ecore_x_window_shape_window_set(Ecore_X_Window win,
66 Ecore_X_Window shape_win)
68 LOGFN(__FILE__, __LINE__, __FUNCTION__);
71 #ifdef ECORE_XCB_SHAPE
72 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
73 XCB_SHAPE_SK_BOUNDING, win, 0, 0, shape_win);
83 ecore_x_window_shape_window_set_xy(Ecore_X_Window win,
84 Ecore_X_Window shape_win,
88 LOGFN(__FILE__, __LINE__, __FUNCTION__);
91 #ifdef ECORE_XCB_SHAPE
92 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
93 XCB_SHAPE_SK_BOUNDING, win, x, y, shape_win);
105 ecore_x_window_shape_rectangle_set(Ecore_X_Window win,
111 #ifdef ECORE_XCB_SHAPE
112 xcb_rectangle_t rect;
115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
118 #ifdef ECORE_XCB_SHAPE
123 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
124 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
125 win, 0, 0, 1, &rect);
138 ecore_x_window_shape_rectangles_set(Ecore_X_Window win,
139 Ecore_X_Rectangle *rects,
142 #ifdef ECORE_XCB_SHAPE
143 xcb_rectangle_t *rect = NULL;
146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
151 #ifdef ECORE_XCB_SHAPE
156 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
159 for (i = 0; i < num; i++)
161 rect[i].x = rects[i].x;
162 rect[i].y = rects[i].y;
163 rect[i].width = rects[i].width;
164 rect[i].height = rects[i].height;
167 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
168 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
169 win, 0, 0, num, (xcb_rectangle_t *)rect);
171 if (rect) free(rect);
182 ecore_x_window_shape_window_add(Ecore_X_Window win,
183 Ecore_X_Window shape_win)
185 LOGFN(__FILE__, __LINE__, __FUNCTION__);
188 #ifdef ECORE_XCB_SHAPE
189 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
190 XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
191 win, 0, 0, shape_win);
201 ecore_x_window_shape_window_add_xy(Ecore_X_Window win,
202 Ecore_X_Window shape_win,
206 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 #ifdef ECORE_XCB_SHAPE
210 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
211 XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
212 win, x, y, shape_win);
224 ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
230 #ifdef ECORE_XCB_SHAPE
231 xcb_rectangle_t rect;
234 LOGFN(__FILE__, __LINE__, __FUNCTION__);
237 #ifdef ECORE_XCB_SHAPE
242 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
243 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
244 win, 0, 0, 1, &rect);
257 ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win,
263 #ifdef ECORE_XCB_SHAPE
264 xcb_rectangle_t rect;
267 LOGFN(__FILE__, __LINE__, __FUNCTION__);
270 #ifdef ECORE_XCB_SHAPE
275 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT,
276 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
277 win, 0, 0, 1, &rect);
290 ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
296 #ifdef ECORE_XCB_SHAPE
297 xcb_rectangle_t rect;
300 LOGFN(__FILE__, __LINE__, __FUNCTION__);
303 #ifdef ECORE_XCB_SHAPE
308 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT,
309 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
310 win, 0, 0, 1, &rect);
323 ecore_x_window_shape_rectangles_add(Ecore_X_Window win,
324 Ecore_X_Rectangle *rects,
327 #ifdef ECORE_XCB_SHAPE
328 xcb_rectangle_t *rect = NULL;
331 LOGFN(__FILE__, __LINE__, __FUNCTION__);
334 #ifdef ECORE_XCB_SHAPE
339 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
342 for (i = 0; i < num; i++)
344 rect[i].x = rects[i].x;
345 rect[i].y = rects[i].y;
346 rect[i].width = rects[i].width;
347 rect[i].height = rects[i].height;
351 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
352 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
353 win, 0, 0, num, (xcb_rectangle_t *)&rect);
355 if (rect) free(rect);
365 EAPI Ecore_X_Rectangle *
366 ecore_x_window_shape_rectangles_get(Ecore_X_Window win,
369 Ecore_X_Rectangle *rects = NULL;
370 #ifdef ECORE_XCB_SHAPE
371 xcb_shape_get_rectangles_cookie_t cookie;
372 xcb_shape_get_rectangles_reply_t *reply;
377 LOGFN(__FILE__, __LINE__, __FUNCTION__);
380 if (num_ret) *num_ret = 0;
382 #ifdef ECORE_XCB_SHAPE
384 xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_BOUNDING);
385 reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
386 if (!reply) return NULL;
387 if (num_ret) *num_ret = reply->rectangles_len;
389 if (reply->rectangles_len < 1)
392 if (num_ret) *num_ret = 0;
396 rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
400 if (num_ret) *num_ret = 0;
403 r = xcb_shape_get_rectangles_rectangles(reply);
404 for (i = 0; i < reply->rectangles_len; i++)
408 rects[i].width = r[i].width;
409 rects[i].height = r[i].height;
422 ecore_x_window_shape_events_select(Ecore_X_Window win,
425 LOGFN(__FILE__, __LINE__, __FUNCTION__);
428 #ifdef ECORE_XCB_SHAPE
429 xcb_shape_select_input(_ecore_xcb_conn, win, on);
438 EAPI Ecore_X_Rectangle *
439 ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win,
442 Ecore_X_Rectangle *rects = NULL;
443 #ifdef ECORE_XCB_SHAPE
444 xcb_shape_get_rectangles_cookie_t cookie;
445 xcb_shape_get_rectangles_reply_t *reply;
450 LOGFN(__FILE__, __LINE__, __FUNCTION__);
453 if (num_ret) *num_ret = 0;
455 #ifdef ECORE_XCB_SHAPE
457 xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_INPUT);
458 reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
459 if (!reply) return NULL;
460 if (num_ret) *num_ret = reply->rectangles_len;
462 if (reply->rectangles_len < 1)
465 if (num_ret) *num_ret = 0;
469 rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
473 if (num_ret) *num_ret = 0;
476 r = xcb_shape_get_rectangles_rectangles(reply);
477 for (i = 0; i < reply->rectangles_len; i++)
481 rects[i].width = r[i].width;
482 rects[i].height = r[i].height;
489 xcb_get_geometry_cookie_t cookie;
490 xcb_get_geometry_reply_t *reply;
492 if (!(rects = malloc(sizeof(Ecore_X_Rectangle))))
496 cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
497 reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
500 rects[0].x = reply->x;
501 rects[0].y = reply->y;
502 rects[0].width = reply->width;
503 rects[0].height = reply->height;
506 if (num_ret) *num_ret = 1;
512 ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win,
513 Ecore_X_Rectangle *rects,
516 #ifdef ECORE_XCB_SHAPE
517 xcb_rectangle_t *rect = NULL;
520 LOGFN(__FILE__, __LINE__, __FUNCTION__);
525 #ifdef ECORE_XCB_SHAPE
530 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
533 for (i = 0; i < num; i++)
535 rect[i].x = rects[i].x;
536 rect[i].y = rects[i].y;
537 rect[i].width = rects[i].width;
538 rect[i].height = rects[i].height;
541 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
542 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
543 win, 0, 0, num, (xcb_rectangle_t *)rect);
545 if (rect) free(rect);
556 ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win,
562 #ifdef ECORE_XCB_SHAPE
563 xcb_rectangle_t rect;
566 LOGFN(__FILE__, __LINE__, __FUNCTION__);
569 #ifdef ECORE_XCB_SHAPE
574 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT,
575 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
576 win, 0, 0, 1, &rect);
589 ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win,
595 #ifdef ECORE_XCB_SHAPE
596 xcb_rectangle_t rect;
599 LOGFN(__FILE__, __LINE__, __FUNCTION__);
602 #ifdef ECORE_XCB_SHAPE
607 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
608 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
609 win, 0, 0, 1, &rect);
622 ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win,
628 #ifdef ECORE_XCB_SHAPE
629 xcb_rectangle_t rect;
632 LOGFN(__FILE__, __LINE__, __FUNCTION__);
635 #ifdef ECORE_XCB_SHAPE
640 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
641 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
642 win, 0, 0, 1, &rect);
655 ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win,
656 Ecore_X_Window shape_win,
660 LOGFN(__FILE__, __LINE__, __FUNCTION__);
663 #ifdef ECORE_XCB_SHAPE
664 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
665 XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
677 ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win,
678 Ecore_X_Window shape_win,
682 LOGFN(__FILE__, __LINE__, __FUNCTION__);
685 #ifdef ECORE_XCB_SHAPE
686 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_INPUT,
687 XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
699 ecore_x_window_shape_input_window_set(Ecore_X_Window win,
700 Ecore_X_Window shape_win)
702 LOGFN(__FILE__, __LINE__, __FUNCTION__);
705 #ifdef ECORE_XCB_SHAPE
706 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
707 XCB_SHAPE_SK_INPUT, win, 0, 0, shape_win);
717 ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win,
723 #ifdef ECORE_XCB_SHAPE
724 xcb_rectangle_t rect;
727 LOGFN(__FILE__, __LINE__, __FUNCTION__);
730 #ifdef ECORE_XCB_SHAPE
735 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT,
736 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
737 win, 0, 0, 1, &rect);
750 ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win,
751 Ecore_X_Rectangle *rects,
754 #ifdef ECORE_XCB_SHAPE
755 xcb_rectangle_t *rect = NULL;
758 LOGFN(__FILE__, __LINE__, __FUNCTION__);
761 #ifdef ECORE_XCB_SHAPE
766 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
769 for (i = 0; i < num; i++)
771 rect[i].x = rects[i].x;
772 rect[i].y = rects[i].y;
773 rect[i].width = rects[i].width;
774 rect[i].height = rects[i].height;
778 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
779 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
780 win, 0, 0, num, (xcb_rectangle_t *)&rect);
782 if (rect) free(rect);