3 #endif /* ifdef HAVE_CONFIG_H */
8 #include "ecore_x_private.h"
12 * @defgroup Ecore_X_Window_Shape X Window Shape Functions
14 * These functions use the shape extension of the X server to change
15 * shape of given windows.
19 * Sets the shape of the given window to that given by the pixmap @p mask.
20 * @param win The given window.
21 * @param mask A 2-bit depth pixmap that provides the new shape of the
23 * @ingroup Ecore_X_Window_Shape
26 ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask)
28 LOGFN(__FILE__, __LINE__, __FUNCTION__);
29 XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet);
30 } /* ecore_x_window_shape_mask_set */
33 * Sets the input shape of the given window to that given by the pixmap @p mask.
34 * @param win The given window.
35 * @param mask A 1-bit depth pixmap that provides the new input shape of the
37 * @ingroup Ecore_X_Window_Shape
40 ecore_x_window_shape_input_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask)
42 LOGFN(__FILE__, __LINE__, __FUNCTION__);
44 XShapeCombineMask(_ecore_x_disp, win, ShapeInput, 0, 0, mask, ShapeSet);
45 #else /* ifdef ShapeInput */
48 #endif /* ifdef ShapeInput */
49 } /* ecore_x_window_shape_input_mask_set */
52 ecore_x_window_shape_window_set(Ecore_X_Window win, Ecore_X_Window shape_win)
54 LOGFN(__FILE__, __LINE__, __FUNCTION__);
55 XShapeCombineShape(_ecore_x_disp,
63 } /* ecore_x_window_shape_window_set */
66 ecore_x_window_shape_input_window_set(Ecore_X_Window win,
67 Ecore_X_Window shape_win)
70 LOGFN(__FILE__, __LINE__, __FUNCTION__);
71 XShapeCombineShape(_ecore_x_disp,
83 } /* ecore_x_window_shape_input_window_set */
86 ecore_x_window_shape_window_set_xy(Ecore_X_Window win,
87 Ecore_X_Window shape_win,
91 LOGFN(__FILE__, __LINE__, __FUNCTION__);
92 XShapeCombineShape(_ecore_x_disp,
100 } /* ecore_x_window_shape_window_set_xy */
103 ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win,
104 Ecore_X_Window shape_win,
109 LOGFN(__FILE__, __LINE__, __FUNCTION__);
110 XShapeCombineShape(_ecore_x_disp,
120 win = shape_win = x = y = 0;
122 } /* ecore_x_window_shape_input_window_set_xy */
125 ecore_x_window_shape_rectangle_set(Ecore_X_Window win,
133 LOGFN(__FILE__, __LINE__, __FUNCTION__);
138 XShapeCombineRectangles(_ecore_x_disp,
147 } /* ecore_x_window_shape_rectangle_set */
150 ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win,
159 LOGFN(__FILE__, __LINE__, __FUNCTION__);
164 XShapeCombineRectangles(_ecore_x_disp,
175 win = x = y = w = h = 0;
177 } /* ecore_x_window_shape_input_rectangle_set */
180 ecore_x_window_shape_rectangles_set(Ecore_X_Window win,
181 Ecore_X_Rectangle *rects,
185 XRectangle *rect = NULL;
188 LOGFN(__FILE__, __LINE__, __FUNCTION__);
192 rect = malloc(sizeof(XRectangle) * num);
194 for (i = 0; i < num; i++)
196 rect[i].x = rects[i].x;
197 rect[i].y = rects[i].y;
198 rect[i].width = rects[i].width;
199 rect[i].height = rects[i].height;
202 XShapeCombineRectangles(_ecore_x_disp,
211 if (rect) free(rect);
214 win = rects = num = 0;
216 } /* ecore_x_window_shape_rectangles_set */
219 ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win,
220 Ecore_X_Rectangle *rects,
224 XRectangle *rect = NULL;
227 LOGFN(__FILE__, __LINE__, __FUNCTION__);
231 rect = malloc(sizeof(XRectangle) * num);
233 for (i = 0; i < num; i++)
235 rect[i].x = rects[i].x;
236 rect[i].y = rects[i].y;
237 rect[i].width = rects[i].width;
238 rect[i].height = rects[i].height;
241 XShapeCombineRectangles(_ecore_x_disp,
250 if (rect) free(rect);
253 win = rects = num = 0;
255 } /* ecore_x_window_shape_input_rectangles_set */
258 ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win,
266 LOGFN(__FILE__, __LINE__, __FUNCTION__);
271 XShapeCombineRectangles(_ecore_x_disp,
280 } /* ecore_x_window_shape_rectangle_subtract */
283 ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win,
292 LOGFN(__FILE__, __LINE__, __FUNCTION__);
297 XShapeCombineRectangles(_ecore_x_disp,
308 win = x = y = w = h = 0;
310 } /* ecore_x_window_shape_input_rectangle_subtract */
313 ecore_x_window_shape_window_add(Ecore_X_Window win, Ecore_X_Window shape_win)
315 LOGFN(__FILE__, __LINE__, __FUNCTION__);
316 XShapeCombineShape(_ecore_x_disp,
324 } /* ecore_x_window_shape_window_add */
327 ecore_x_window_shape_window_add_xy(Ecore_X_Window win,
328 Ecore_X_Window shape_win,
332 LOGFN(__FILE__, __LINE__, __FUNCTION__);
333 XShapeCombineShape(_ecore_x_disp,
341 } /* ecore_x_window_shape_window_add_xy */
344 ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win,
345 Ecore_X_Window shape_win,
350 LOGFN(__FILE__, __LINE__, __FUNCTION__);
351 XShapeCombineShape(_ecore_x_disp,
361 win = shape_win = x = y = 0;
363 } /* ecore_x_window_shape_input_window_add_xy */
366 ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
374 LOGFN(__FILE__, __LINE__, __FUNCTION__);
379 XShapeCombineRectangles(_ecore_x_disp,
388 } /* ecore_x_window_shape_rectangle_add */
391 ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win,
400 LOGFN(__FILE__, __LINE__, __FUNCTION__);
405 XShapeCombineRectangles(_ecore_x_disp,
416 win = x = y = w = h = 0;
418 } /* ecore_x_window_shape_input_rectangle_add */
421 ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
429 LOGFN(__FILE__, __LINE__, __FUNCTION__);
434 XShapeCombineRectangles(_ecore_x_disp,
443 } /* ecore_x_window_shape_rectangle_clip */
446 ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win,
455 LOGFN(__FILE__, __LINE__, __FUNCTION__);
460 XShapeCombineRectangles(_ecore_x_disp,
471 win = x = y = w = h = 0;
473 } /* ecore_x_window_shape_input_rectangle_clip */
476 ecore_x_window_shape_rectangles_add(Ecore_X_Window win,
477 Ecore_X_Rectangle *rects,
480 XRectangle *rect = NULL;
483 LOGFN(__FILE__, __LINE__, __FUNCTION__);
486 rect = malloc(sizeof(XRectangle) * num);
488 for (i = 0; i < num; i++)
490 rect[i].x = rects[i].x;
491 rect[i].y = rects[i].y;
492 rect[i].width = rects[i].width;
493 rect[i].height = rects[i].height;
497 XShapeCombineRectangles(_ecore_x_disp,
506 if (rect) free(rect);
507 } /* ecore_x_window_shape_rectangles_add */
510 ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win,
511 Ecore_X_Rectangle *rects,
515 XRectangle *rect = NULL;
518 LOGFN(__FILE__, __LINE__, __FUNCTION__);
521 rect = malloc(sizeof(XRectangle) * num);
523 for (i = 0; i < num; i++)
525 rect[i].x = rects[i].x;
526 rect[i].y = rects[i].y;
527 rect[i].width = rects[i].width;
528 rect[i].height = rects[i].height;
532 XShapeCombineRectangles(_ecore_x_disp,
541 if (rect) free(rect);
544 win = rects = num = 0;
546 } /* ecore_x_window_shape_input_rectangles_add */
548 EAPI Ecore_X_Rectangle *
549 ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret)
552 Ecore_X_Rectangle *rects = NULL;
555 LOGFN(__FILE__, __LINE__, __FUNCTION__);
556 rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeBounding, &num, &ord);
562 if (num_ret) *num_ret = 0;
565 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
569 if (num_ret) *num_ret = 0;
572 for (i = 0; i < num; i++)
574 rects[i].x = rect[i].x;
575 rects[i].y = rect[i].y;
576 rects[i].width = rect[i].width;
577 rects[i].height = rect[i].height;
581 if (num_ret) *num_ret = num;
583 } /* ecore_x_window_shape_rectangles_get */
585 EAPI Ecore_X_Rectangle *
586 ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret)
588 Ecore_X_Rectangle *rects = NULL;
593 LOGFN(__FILE__, __LINE__, __FUNCTION__);
594 rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeInput, &num, &ord);
600 if (num_ret) *num_ret = 0;
603 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
607 if (num_ret) *num_ret = 0;
610 for (i = 0; i < num; i++)
612 rects[i].x = rect[i].x;
613 rects[i].y = rect[i].y;
614 rects[i].width = rect[i].width;
615 rects[i].height = rect[i].height;
619 if (num_ret) *num_ret = num;
622 // have to return fake shape input rect of size of window
626 if (num_ret) *num_ret = 0;
627 rects = malloc(sizeof(Ecore_X_Rectangle));
628 if (!rects) return NULL;
629 if (!XGetGeometry(_ecore_x_disp, win, &dw,
630 &(rects[0].x), &(rects[0].y),
631 &(rects[0].width), &(rects[0].height),
637 if (num_ret) *num_ret = 1;
640 } /* ecore_x_window_shape_input_rectangles_get */
643 ecore_x_window_shape_events_select(Ecore_X_Window win, Eina_Bool on)
645 LOGFN(__FILE__, __LINE__, __FUNCTION__);
647 XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
649 XShapeSelectInput(_ecore_x_disp, win, 0);
650 } /* ecore_x_window_shape_events_select */