1 #include "ecore_xcb_private.h"
3 # include <xcb/shape.h>
7 * @defgroup Ecore_X_Window_Shape X Window Shape Functions
9 * These functions use the shape extension of the X server to change
10 * shape of given windows.
14 * Sets the input shape of the given window to that given by the pixmap @p mask.
15 * @param win The given window.
16 * @param mask A 1-bit depth pixmap that provides the new input shape of the
18 * @ingroup Ecore_X_Window_Shape
21 ecore_x_window_shape_input_mask_set(Ecore_X_Window win,
24 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27 #ifdef ECORE_XCB_SHAPE
28 xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
39 * Sets the shape of the given window to that given by the pixmap @p mask.
40 * @param win The given window.
41 * @param mask A 2-bit depth pixmap that provides the new shape of the
43 * @ingroup Ecore_X_Window_Shape
46 ecore_x_window_shape_mask_set(Ecore_X_Window win,
49 LOGFN(__FILE__, __LINE__, __FUNCTION__);
52 #ifdef ECORE_XCB_SHAPE
53 xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
64 ecore_x_window_shape_window_set(Ecore_X_Window win,
65 Ecore_X_Window shape_win)
67 LOGFN(__FILE__, __LINE__, __FUNCTION__);
70 #ifdef ECORE_XCB_SHAPE
71 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
72 XCB_SHAPE_SK_BOUNDING, win, 0, 0, shape_win);
82 ecore_x_window_shape_window_set_xy(Ecore_X_Window win,
83 Ecore_X_Window shape_win,
87 LOGFN(__FILE__, __LINE__, __FUNCTION__);
90 #ifdef ECORE_XCB_SHAPE
91 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
92 XCB_SHAPE_SK_BOUNDING, win, x, y, shape_win);
104 ecore_x_window_shape_rectangle_set(Ecore_X_Window win,
110 #ifdef ECORE_XCB_SHAPE
111 xcb_rectangle_t rect;
114 LOGFN(__FILE__, __LINE__, __FUNCTION__);
117 #ifdef ECORE_XCB_SHAPE
122 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
123 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
124 win, 0, 0, 1, &rect);
137 ecore_x_window_shape_rectangles_set(Ecore_X_Window win,
138 Ecore_X_Rectangle *rects,
141 #ifdef ECORE_XCB_SHAPE
142 xcb_rectangle_t *rect = NULL;
145 LOGFN(__FILE__, __LINE__, __FUNCTION__);
150 #ifdef ECORE_XCB_SHAPE
155 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
158 for (i = 0; i < num; i++)
160 rect[i].x = rects[i].x;
161 rect[i].y = rects[i].y;
162 rect[i].width = rects[i].width;
163 rect[i].height = rects[i].height;
166 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
167 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
168 win, 0, 0, num, (xcb_rectangle_t *)rect);
170 if (rect) free(rect);
181 ecore_x_window_shape_window_add(Ecore_X_Window win,
182 Ecore_X_Window shape_win)
184 LOGFN(__FILE__, __LINE__, __FUNCTION__);
187 #ifdef ECORE_XCB_SHAPE
188 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
189 XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
190 win, 0, 0, shape_win);
200 ecore_x_window_shape_window_add_xy(Ecore_X_Window win,
201 Ecore_X_Window shape_win,
205 LOGFN(__FILE__, __LINE__, __FUNCTION__);
208 #ifdef ECORE_XCB_SHAPE
209 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
210 XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
211 win, x, y, shape_win);
223 ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
229 #ifdef ECORE_XCB_SHAPE
230 xcb_rectangle_t rect;
233 LOGFN(__FILE__, __LINE__, __FUNCTION__);
236 #ifdef ECORE_XCB_SHAPE
241 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
242 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
243 win, 0, 0, 1, &rect);
256 ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win,
262 #ifdef ECORE_XCB_SHAPE
263 xcb_rectangle_t rect;
266 LOGFN(__FILE__, __LINE__, __FUNCTION__);
269 #ifdef ECORE_XCB_SHAPE
274 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT,
275 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
276 win, 0, 0, 1, &rect);
289 ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
295 #ifdef ECORE_XCB_SHAPE
296 xcb_rectangle_t rect;
299 LOGFN(__FILE__, __LINE__, __FUNCTION__);
302 #ifdef ECORE_XCB_SHAPE
307 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT,
308 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
309 win, 0, 0, 1, &rect);
322 ecore_x_window_shape_rectangles_add(Ecore_X_Window win,
323 Ecore_X_Rectangle *rects,
326 #ifdef ECORE_XCB_SHAPE
327 xcb_rectangle_t *rect = NULL;
330 LOGFN(__FILE__, __LINE__, __FUNCTION__);
333 #ifdef ECORE_XCB_SHAPE
338 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
341 for (i = 0; i < num; i++)
343 rect[i].x = rects[i].x;
344 rect[i].y = rects[i].y;
345 rect[i].width = rects[i].width;
346 rect[i].height = rects[i].height;
350 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
351 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
352 win, 0, 0, num, (xcb_rectangle_t *)&rect);
354 if (rect) free(rect);
364 EAPI Ecore_X_Rectangle *
365 ecore_x_window_shape_rectangles_get(Ecore_X_Window win,
368 Ecore_X_Rectangle *rects = NULL;
369 #ifdef ECORE_XCB_SHAPE
370 xcb_shape_get_rectangles_cookie_t cookie;
371 xcb_shape_get_rectangles_reply_t *reply;
376 LOGFN(__FILE__, __LINE__, __FUNCTION__);
379 if (num_ret) *num_ret = 0;
381 #ifdef ECORE_XCB_SHAPE
383 xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_BOUNDING);
384 reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
385 if (!reply) return NULL;
386 if (num_ret) *num_ret = reply->rectangles_len;
388 if (reply->rectangles_len < 1)
391 if (num_ret) *num_ret = 0;
395 rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
399 if (num_ret) *num_ret = 0;
402 r = xcb_shape_get_rectangles_rectangles(reply);
403 for (i = 0; i < reply->rectangles_len; i++)
407 rects[i].width = r[i].width;
408 rects[i].height = r[i].height;
421 ecore_x_window_shape_events_select(Ecore_X_Window win,
424 LOGFN(__FILE__, __LINE__, __FUNCTION__);
427 #ifdef ECORE_XCB_SHAPE
428 xcb_shape_select_input(_ecore_xcb_conn, win, on);
437 EAPI Ecore_X_Rectangle *
438 ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win,
441 Ecore_X_Rectangle *rects = NULL;
442 #ifdef ECORE_XCB_SHAPE
443 xcb_shape_get_rectangles_cookie_t cookie;
444 xcb_shape_get_rectangles_reply_t *reply;
449 LOGFN(__FILE__, __LINE__, __FUNCTION__);
452 if (num_ret) *num_ret = 0;
454 #ifdef ECORE_XCB_SHAPE
456 xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_INPUT);
457 reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
458 if (!reply) return NULL;
459 if (num_ret) *num_ret = reply->rectangles_len;
461 if (reply->rectangles_len < 1)
464 if (num_ret) *num_ret = 0;
468 rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
472 if (num_ret) *num_ret = 0;
475 r = xcb_shape_get_rectangles_rectangles(reply);
476 for (i = 0; i < reply->rectangles_len; i++)
480 rects[i].width = r[i].width;
481 rects[i].height = r[i].height;
488 xcb_get_geometry_cookie_t cookie;
489 xcb_get_geometry_reply_t *reply;
491 if (!(rects = malloc(sizeof(Ecore_X_Rectangle))))
495 cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
496 reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
499 rects[0].x = reply->x;
500 rects[0].y = reply->y;
501 rects[0].width = reply->width;
502 rects[0].height = reply->height;
505 if (num_ret) *num_ret = 1;
511 ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win,
512 Ecore_X_Rectangle *rects,
515 #ifdef ECORE_XCB_SHAPE
516 xcb_rectangle_t *rect = NULL;
519 LOGFN(__FILE__, __LINE__, __FUNCTION__);
524 #ifdef ECORE_XCB_SHAPE
529 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
532 for (i = 0; i < num; i++)
534 rect[i].x = rects[i].x;
535 rect[i].y = rects[i].y;
536 rect[i].width = rects[i].width;
537 rect[i].height = rects[i].height;
540 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
541 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
542 win, 0, 0, num, (xcb_rectangle_t *)rect);
544 if (rect) free(rect);
555 ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win,
561 #ifdef ECORE_XCB_SHAPE
562 xcb_rectangle_t rect;
565 LOGFN(__FILE__, __LINE__, __FUNCTION__);
568 #ifdef ECORE_XCB_SHAPE
573 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT,
574 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
575 win, 0, 0, 1, &rect);
588 ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win,
594 #ifdef ECORE_XCB_SHAPE
595 xcb_rectangle_t rect;
598 LOGFN(__FILE__, __LINE__, __FUNCTION__);
601 #ifdef ECORE_XCB_SHAPE
606 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
607 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
608 win, 0, 0, 1, &rect);
621 ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win,
627 #ifdef ECORE_XCB_SHAPE
628 xcb_rectangle_t rect;
631 LOGFN(__FILE__, __LINE__, __FUNCTION__);
634 #ifdef ECORE_XCB_SHAPE
639 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
640 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
641 win, 0, 0, 1, &rect);
654 ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win,
655 Ecore_X_Window shape_win,
659 LOGFN(__FILE__, __LINE__, __FUNCTION__);
662 #ifdef ECORE_XCB_SHAPE
663 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
664 XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
676 ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win,
677 Ecore_X_Window shape_win,
681 LOGFN(__FILE__, __LINE__, __FUNCTION__);
684 #ifdef ECORE_XCB_SHAPE
685 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_INPUT,
686 XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
698 ecore_x_window_shape_input_window_set(Ecore_X_Window win,
699 Ecore_X_Window shape_win)
701 LOGFN(__FILE__, __LINE__, __FUNCTION__);
704 #ifdef ECORE_XCB_SHAPE
705 xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
706 XCB_SHAPE_SK_INPUT, win, 0, 0, shape_win);
716 ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win,
722 #ifdef ECORE_XCB_SHAPE
723 xcb_rectangle_t rect;
726 LOGFN(__FILE__, __LINE__, __FUNCTION__);
729 #ifdef ECORE_XCB_SHAPE
734 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT,
735 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
736 win, 0, 0, 1, &rect);
749 ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win,
750 Ecore_X_Rectangle *rects,
753 #ifdef ECORE_XCB_SHAPE
754 xcb_rectangle_t *rect = NULL;
757 LOGFN(__FILE__, __LINE__, __FUNCTION__);
760 #ifdef ECORE_XCB_SHAPE
765 if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
768 for (i = 0; i < num; i++)
770 rect[i].x = rects[i].x;
771 rect[i].y = rects[i].y;
772 rect[i].width = rects[i].width;
773 rect[i].height = rects[i].height;
777 xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
778 XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
779 win, 0, 0, num, (xcb_rectangle_t *)&rect);
781 if (rect) free(rect);