eolian: rename is_ref API to is_ptr to match syntax
[platform/upstream/efl.git] / src / lib / ecore_x / xcb / ecore_xcb_window_shape.c
1 #include "ecore_xcb_private.h"
2 #ifdef ECORE_XCB_SHAPE
3 # include <xcb/shape.h>
4 #endif
5
6 /**
7  * @defgroup Ecore_X_Window_Shape X Window Shape Functions
8  * @ingroup Ecore_X_Group
9  *
10  * These functions use the shape extension of the X server to change
11  * shape of given windows.
12  */
13
14 /**
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
18  *               window.
19  * @ingroup Ecore_X_Window_Shape
20  */
21 EAPI void
22 ecore_x_window_shape_input_mask_set(Ecore_X_Window win,
23                                     Ecore_X_Pixmap mask)
24 {
25    LOGFN(__FILE__, __LINE__, __FUNCTION__);
26    CHECK_XCB_CONN;
27
28 #ifdef ECORE_XCB_SHAPE
29    xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
30                   win, 0, 0, mask);
31 //   ecore_x_flush();
32 #else
33    return;
34    win = 0;
35    mask = 0;
36 #endif
37 }
38
39 /**
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
43  *               window.
44  * @ingroup Ecore_X_Window_Shape
45  */
46 EAPI void
47 ecore_x_window_shape_mask_set(Ecore_X_Window win,
48                               Ecore_X_Pixmap mask)
49 {
50    LOGFN(__FILE__, __LINE__, __FUNCTION__);
51    CHECK_XCB_CONN;
52
53 #ifdef ECORE_XCB_SHAPE
54    xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
55                   win, 0, 0, mask);
56 //   ecore_x_flush();
57 #else
58    return;
59    win = 0;
60    mask = 0;
61 #endif
62 }
63
64 EAPI void
65 ecore_x_window_shape_window_set(Ecore_X_Window win,
66                                 Ecore_X_Window shape_win)
67 {
68    LOGFN(__FILE__, __LINE__, __FUNCTION__);
69    CHECK_XCB_CONN;
70
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);
74 //   ecore_x_flush();
75 #else
76    return;
77    win = 0;
78    shape_win = 0;
79 #endif
80 }
81
82 EAPI void
83 ecore_x_window_shape_window_set_xy(Ecore_X_Window win,
84                                    Ecore_X_Window shape_win,
85                                    int            x,
86                                    int            y)
87 {
88    LOGFN(__FILE__, __LINE__, __FUNCTION__);
89    CHECK_XCB_CONN;
90
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);
94 //   ecore_x_flush();
95 #else
96    return;
97    win = 0;
98    shape_win = 0;
99    x = 0;
100    y = 0;
101 #endif
102 }
103
104 EAPI void
105 ecore_x_window_shape_rectangle_set(Ecore_X_Window win,
106                                    int            x,
107                                    int            y,
108                                    int            w,
109                                    int            h)
110 {
111 #ifdef ECORE_XCB_SHAPE
112    xcb_rectangle_t rect;
113 #endif
114
115    LOGFN(__FILE__, __LINE__, __FUNCTION__);
116    CHECK_XCB_CONN;
117
118 #ifdef ECORE_XCB_SHAPE
119    rect.x = x;
120    rect.y = y;
121    rect.width = w;
122    rect.height = h;
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);
126 //   ecore_x_flush();
127 #else
128    return;
129    win = 0;
130    x = 0;
131    y = 0;
132    w = 0;
133    h = 0;
134 #endif
135 }
136
137 EAPI void
138 ecore_x_window_shape_rectangles_set(Ecore_X_Window     win,
139                                     Ecore_X_Rectangle *rects,
140                                     int                num)
141 {
142 #ifdef ECORE_XCB_SHAPE
143    xcb_rectangle_t *rect = NULL;
144 #endif
145
146    LOGFN(__FILE__, __LINE__, __FUNCTION__);
147    CHECK_XCB_CONN;
148
149    if (!rects) return;
150
151 #ifdef ECORE_XCB_SHAPE
152    if (num > 0)
153      {
154         int i = 0;
155
156         if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
157           return;
158
159         for (i = 0; i < num; i++)
160           {
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;
165           }
166      }
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);
170
171    if (rect) free(rect);
172 //   ecore_x_flush();
173 #else
174    return;
175    win = 0;
176    num = 0;
177    rects = NULL;
178 #endif
179 }
180
181 EAPI void
182 ecore_x_window_shape_window_add(Ecore_X_Window win,
183                                 Ecore_X_Window shape_win)
184 {
185    LOGFN(__FILE__, __LINE__, __FUNCTION__);
186    CHECK_XCB_CONN;
187
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);
192 //   ecore_x_flush();
193 #else
194    return;
195    win = 0;
196    shape_win = 0;
197 #endif
198 }
199
200 EAPI void
201 ecore_x_window_shape_window_add_xy(Ecore_X_Window win,
202                                    Ecore_X_Window shape_win,
203                                    int            x,
204                                    int            y)
205 {
206    LOGFN(__FILE__, __LINE__, __FUNCTION__);
207    CHECK_XCB_CONN;
208
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);
213 //   ecore_x_flush();
214 #else
215    return;
216    win = 0;
217    shape_win = 0;
218    x = 0;
219    y = 0;
220 #endif
221 }
222
223 EAPI void
224 ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
225                                    int            x,
226                                    int            y,
227                                    int            w,
228                                    int            h)
229 {
230 #ifdef ECORE_XCB_SHAPE
231    xcb_rectangle_t rect;
232 #endif
233
234    LOGFN(__FILE__, __LINE__, __FUNCTION__);
235    CHECK_XCB_CONN;
236
237 #ifdef ECORE_XCB_SHAPE
238    rect.x = x;
239    rect.y = y;
240    rect.width = w;
241    rect.height = h;
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);
245 //   ecore_x_flush();
246 #else
247    return;
248    win = 0;
249    x = 0;
250    y = 0;
251    w = 0;
252    h = 0;
253 #endif
254 }
255
256 EAPI void
257 ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win,
258                                         int            x,
259                                         int            y,
260                                         int            w,
261                                         int            h)
262 {
263 #ifdef ECORE_XCB_SHAPE
264    xcb_rectangle_t rect;
265 #endif
266
267    LOGFN(__FILE__, __LINE__, __FUNCTION__);
268    CHECK_XCB_CONN;
269
270 #ifdef ECORE_XCB_SHAPE
271    rect.x = x;
272    rect.y = y;
273    rect.width = w;
274    rect.height = h;
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);
278 //   ecore_x_flush();
279 #else
280    return;
281    win = 0;
282    x = 0;
283    y = 0;
284    w = 0;
285    h = 0;
286 #endif
287 }
288
289 EAPI void
290 ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
291                                     int            x,
292                                     int            y,
293                                     int            w,
294                                     int            h)
295 {
296 #ifdef ECORE_XCB_SHAPE
297    xcb_rectangle_t rect;
298 #endif
299
300    LOGFN(__FILE__, __LINE__, __FUNCTION__);
301    CHECK_XCB_CONN;
302
303 #ifdef ECORE_XCB_SHAPE
304    rect.x = x;
305    rect.y = y;
306    rect.width = w;
307    rect.height = h;
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);
311 //   ecore_x_flush();
312 #else
313    return;
314    win = 0;
315    x = 0;
316    y = 0;
317    w = 0;
318    h = 0;
319 #endif
320 }
321
322 EAPI void
323 ecore_x_window_shape_rectangles_add(Ecore_X_Window     win,
324                                     Ecore_X_Rectangle *rects,
325                                     int                num)
326 {
327 #ifdef ECORE_XCB_SHAPE
328    xcb_rectangle_t *rect = NULL;
329 #endif
330
331    LOGFN(__FILE__, __LINE__, __FUNCTION__);
332    CHECK_XCB_CONN;
333
334 #ifdef ECORE_XCB_SHAPE
335    if (num > 0)
336      {
337         int i = 0;
338
339         if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
340           return;
341
342         for (i = 0; i < num; i++)
343           {
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;
348           }
349      }
350
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);
354
355    if (rect) free(rect);
356 //   ecore_x_flush();
357 #else
358    return;
359    win = 0;
360    num = 0;
361    rects = NULL;
362 #endif
363 }
364
365 EAPI Ecore_X_Rectangle *
366 ecore_x_window_shape_rectangles_get(Ecore_X_Window win,
367                                     int           *num_ret)
368 {
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;
373    xcb_rectangle_t *r;
374    unsigned int i = 0;
375 #endif
376
377    LOGFN(__FILE__, __LINE__, __FUNCTION__);
378    CHECK_XCB_CONN;
379
380    if (num_ret) *num_ret = 0;
381
382 #ifdef ECORE_XCB_SHAPE
383    cookie =
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;
388
389    if (reply->rectangles_len < 1)
390      {
391         free(reply);
392         if (num_ret) *num_ret = 0;
393         return NULL;
394      }
395
396    rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
397    if (!rects)
398      {
399         free(reply);
400         if (num_ret) *num_ret = 0;
401         return NULL;
402      }
403    r = xcb_shape_get_rectangles_rectangles(reply);
404    for (i = 0; i < reply->rectangles_len; i++)
405      {
406         rects[i].x = r[i].x;
407         rects[i].y = r[i].y;
408         rects[i].width = r[i].width;
409         rects[i].height = r[i].height;
410      }
411
412    free(reply);
413
414    return rects;
415 #else
416    return rects;
417    win = 0;
418 #endif
419 }
420
421 EAPI void
422 ecore_x_window_shape_events_select(Ecore_X_Window win,
423                                    Eina_Bool      on)
424 {
425    LOGFN(__FILE__, __LINE__, __FUNCTION__);
426    CHECK_XCB_CONN;
427
428 #ifdef ECORE_XCB_SHAPE
429    xcb_shape_select_input(_ecore_xcb_conn, win, on);
430 //   ecore_x_flush();
431 #else
432    return;
433    win = 0;
434    on = 0;
435 #endif
436 }
437
438 EAPI Ecore_X_Rectangle *
439 ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win,
440                                           int           *num_ret)
441 {
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;
446    xcb_rectangle_t *r;
447    unsigned int i = 0;
448 #endif
449
450    LOGFN(__FILE__, __LINE__, __FUNCTION__);
451    CHECK_XCB_CONN;
452
453    if (num_ret) *num_ret = 0;
454
455 #ifdef ECORE_XCB_SHAPE
456    cookie =
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;
461
462    if (reply->rectangles_len < 1)
463      {
464         free(reply);
465         if (num_ret) *num_ret = 0;
466         return NULL;
467      }
468
469    rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
470    if (!rects)
471      {
472         free(reply);
473         if (num_ret) *num_ret = 0;
474         return NULL;
475      }
476    r = xcb_shape_get_rectangles_rectangles(reply);
477    for (i = 0; i < reply->rectangles_len; i++)
478      {
479         rects[i].x = r[i].x;
480         rects[i].y = r[i].y;
481         rects[i].width = r[i].width;
482         rects[i].height = r[i].height;
483      }
484
485    free(reply);
486
487    return rects;
488 #else
489    xcb_get_geometry_cookie_t cookie;
490    xcb_get_geometry_reply_t *reply;
491
492    if (!(rects = malloc(sizeof(Ecore_X_Rectangle))))
493      return NULL;
494
495    /* get geometry */
496    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
497    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
498    if (reply)
499      {
500         rects[0].x = reply->x;
501         rects[0].y = reply->y;
502         rects[0].width = reply->width;
503         rects[0].height = reply->height;
504         free(reply);
505      }
506    if (num_ret) *num_ret = 1;
507    return rects;
508 #endif
509 }
510
511 EAPI void
512 ecore_x_window_shape_input_rectangles_set(Ecore_X_Window     win,
513                                           Ecore_X_Rectangle *rects,
514                                           int                num)
515 {
516 #ifdef ECORE_XCB_SHAPE
517    xcb_rectangle_t *rect = NULL;
518 #endif
519
520    LOGFN(__FILE__, __LINE__, __FUNCTION__);
521    CHECK_XCB_CONN;
522
523    if (!rects) return;
524
525 #ifdef ECORE_XCB_SHAPE
526    if (num > 0)
527      {
528         int i = 0;
529
530         if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
531           return;
532
533         for (i = 0; i < num; i++)
534           {
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;
539           }
540      }
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);
544
545    if (rect) free(rect);
546 //   ecore_x_flush();
547 #else
548    return;
549    win = 0;
550    num = 0;
551    rects = NULL;
552 #endif
553 }
554
555 EAPI void
556 ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win,
557                                               int            x,
558                                               int            y,
559                                               int            w,
560                                               int            h)
561 {
562 #ifdef ECORE_XCB_SHAPE
563    xcb_rectangle_t rect;
564 #endif
565
566    LOGFN(__FILE__, __LINE__, __FUNCTION__);
567    CHECK_XCB_CONN;
568
569 #ifdef ECORE_XCB_SHAPE
570    rect.x = x;
571    rect.y = y;
572    rect.width = w;
573    rect.height = h;
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);
577 //   ecore_x_flush();
578 #else
579    return;
580    win = 0;
581    x = 0;
582    y = 0;
583    w = 0;
584    h = 0;
585 #endif
586 }
587
588 EAPI void
589 ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win,
590                                          int            x,
591                                          int            y,
592                                          int            w,
593                                          int            h)
594 {
595 #ifdef ECORE_XCB_SHAPE
596    xcb_rectangle_t rect;
597 #endif
598
599    LOGFN(__FILE__, __LINE__, __FUNCTION__);
600    CHECK_XCB_CONN;
601
602 #ifdef ECORE_XCB_SHAPE
603    rect.x = x;
604    rect.y = y;
605    rect.width = w;
606    rect.height = h;
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);
610 //   ecore_x_flush();
611 #else
612    return;
613    win = 0;
614    x = 0;
615    y = 0;
616    w = 0;
617    h = 0;
618 #endif
619 }
620
621 EAPI void
622 ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win,
623                                          int            x,
624                                          int            y,
625                                          int            w,
626                                          int            h)
627 {
628 #ifdef ECORE_XCB_SHAPE
629    xcb_rectangle_t rect;
630 #endif
631
632    LOGFN(__FILE__, __LINE__, __FUNCTION__);
633    CHECK_XCB_CONN;
634
635 #ifdef ECORE_XCB_SHAPE
636    rect.x = x;
637    rect.y = y;
638    rect.width = w;
639    rect.height = h;
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);
643 //   ecore_x_flush();
644 #else
645    return;
646    win = 0;
647    x = 0;
648    y = 0;
649    w = 0;
650    h = 0;
651 #endif
652 }
653
654 EAPI void
655 ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win,
656                                          Ecore_X_Window shape_win,
657                                          int            x,
658                                          int            y)
659 {
660    LOGFN(__FILE__, __LINE__, __FUNCTION__);
661    CHECK_XCB_CONN;
662
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);
666 //   ecore_x_flush();
667 #else
668    return;
669    win = 0;
670    shape_win = 0;
671    x = 0;
672    y = 0;
673 #endif
674 }
675
676 EAPI void
677 ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win,
678                                          Ecore_X_Window shape_win,
679                                          int            x,
680                                          int            y)
681 {
682    LOGFN(__FILE__, __LINE__, __FUNCTION__);
683    CHECK_XCB_CONN;
684
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);
688 //   ecore_x_flush();
689 #else
690    return;
691    win = 0;
692    shape_win = 0;
693    x = 0;
694    y = 0;
695 #endif
696 }
697
698 EAPI void
699 ecore_x_window_shape_input_window_set(Ecore_X_Window win,
700                                       Ecore_X_Window shape_win)
701 {
702    LOGFN(__FILE__, __LINE__, __FUNCTION__);
703    CHECK_XCB_CONN;
704
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);
708 //   ecore_x_flush();
709 #else
710    return;
711    win = 0;
712    shape_win = 0;
713 #endif
714 }
715
716 EAPI void
717 ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win,
718                                           int            x,
719                                           int            y,
720                                           int            w,
721                                           int            h)
722 {
723 #ifdef ECORE_XCB_SHAPE
724    xcb_rectangle_t rect;
725 #endif
726
727    LOGFN(__FILE__, __LINE__, __FUNCTION__);
728    CHECK_XCB_CONN;
729
730 #ifdef ECORE_XCB_SHAPE
731    rect.x = x;
732    rect.y = y;
733    rect.width = w;
734    rect.height = h;
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);
738 //   ecore_x_flush();
739 #else
740    return;
741    win = 0;
742    x = 0;
743    y = 0;
744    w = 0;
745    h = 0;
746 #endif
747 }
748
749 EAPI void
750 ecore_x_window_shape_input_rectangles_add(Ecore_X_Window     win,
751                                           Ecore_X_Rectangle *rects,
752                                           int                num)
753 {
754 #ifdef ECORE_XCB_SHAPE
755    xcb_rectangle_t *rect = NULL;
756 #endif
757
758    LOGFN(__FILE__, __LINE__, __FUNCTION__);
759    CHECK_XCB_CONN;
760
761 #ifdef ECORE_XCB_SHAPE
762    if (num > 0)
763      {
764         int i = 0;
765
766         if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
767           return;
768
769         for (i = 0; i < num; i++)
770           {
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;
775           }
776      }
777
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);
781
782    if (rect) free(rect);
783 //   ecore_x_flush();
784 #else
785    return;
786    win = 0;
787    num = 0;
788    rects = NULL;
789 #endif
790 }
791