From 9927ad7294b3205d3ba578e8504f4121e65ddde3 Mon Sep 17 00:00:00 2001 From: raster Date: Wed, 13 Apr 2011 09:06:05 +0000 Subject: [PATCH] From: Doyun Kang Add support for shape input setting and modification (with fixes/modifications and extensions added tomake it more complete). git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@58621 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 4 + src/lib/ecore_evas/Ecore_Evas.h | 8 +- src/lib/ecore_evas/ecore_evas_private.h | 1 + src/lib/ecore_evas/ecore_evas_x.c | 219 ++++++++++++++ src/lib/ecore_x/Ecore_X.h | 59 ++++ src/lib/ecore_x/xlib/ecore_x_composite.c | 28 +- src/lib/ecore_x/xlib/ecore_x_window_shape.c | 450 ++++++++++++++++++++++++---- 7 files changed, 686 insertions(+), 83 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dcd991..a163bb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -127,3 +127,7 @@ 2011-04-11 Hannes Janetzek * Fix removal of windows from ignore_list with ecore_x_window_ignore_set + +2011-04-13 Doyun Kang + + * Ecore_X + Ecore_Evas: Add more support for shape input setting diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h index 54bb215..0063480 100644 --- a/src/lib/ecore_evas/Ecore_Evas.h +++ b/src/lib/ecore_evas/Ecore_Evas.h @@ -363,7 +363,13 @@ EAPI Eina_List *ecore_evas_ecore_evas_list_get(void); EAPI void ecore_evas_x11_leader_set(Ecore_Evas *ee, Ecore_X_Window win); EAPI Ecore_X_Window ecore_evas_x11_leader_get(Ecore_Evas *ee); EAPI void ecore_evas_x11_leader_default_set(Ecore_Evas *ee); - +EAPI void ecore_evas_x11_shape_input_rectangle_set(Ecore_Evas *ee, int x, int y, int w, int h); +EAPI void ecore_evas_x11_shape_input_rectangle_add(Ecore_Evas *ee, int x, int y, int w, int h); +EAPI void ecore_evas_x11_shape_input_rectangle_subtract(Ecore_Evas *ee, int x, int y, int w, int h); +EAPI void ecore_evas_x11_shape_input_empty(Ecore_Evas *ee); +EAPI void ecore_evas_x11_shape_input_reset(Ecore_Evas *ee); +EAPI void ecore_evas_x11_shape_input_apply(Ecore_Evas *ee); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h index 3bbf1c7..2f4f90b 100644 --- a/src/lib/ecore_evas/ecore_evas_private.h +++ b/src/lib/ecore_evas/ecore_evas_private.h @@ -226,6 +226,7 @@ struct _Ecore_Evas_Engine unsigned char above : 1; unsigned char below : 1; } state; + Ecore_X_Window win_shaped_input; } x; #endif #ifdef BUILD_ECORE_EVAS_FB diff --git a/src/lib/ecore_evas/ecore_evas_x.c b/src/lib/ecore_evas/ecore_evas_x.c index f1d0b54..f221296 100644 --- a/src/lib/ecore_evas/ecore_evas_x.c +++ b/src/lib/ecore_evas/ecore_evas_x.c @@ -1297,6 +1297,7 @@ _ecore_evas_x_free(Ecore_Evas *ee) { _ecore_evas_x_group_leader_unset(ee); _ecore_evas_x_sync_set(ee); + if (ee->engine.x.win_shaped_input) ecore_x_window_free(ee->engine.x.win_shaped_input); ecore_x_window_free(ee->prop.window); if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); @@ -4572,3 +4573,221 @@ ecore_evas_x11_leader_default_set(Ecore_Evas *ee) #endif } +static Eina_Bool +_ecore_evas_x11_convert_rectangle_with_angle(Ecore_Evas *ee, Ecore_X_Rectangle *dst_rect, Ecore_X_Rectangle *src_rect) +{ +#ifdef BUILD_ECORE_EVAS_X11 + if (!src_rect || !dst_rect) return 0; + + if (ee->rotation == 0) + { + dst_rect->x = src_rect->x; + dst_rect->y = src_rect->y; + dst_rect->width = src_rect->width; + dst_rect->height = src_rect->height; + } + else if (ee->rotation == 90) + { + dst_rect->x = src_rect->y; + dst_rect->y = ee->req.h - src_rect->x - src_rect->width; + dst_rect->width = src_rect->height; + dst_rect->height = src_rect->width; + } + else if (ee->rotation == 180) + { + dst_rect->x = ee->req.w - src_rect->x - src_rect->width; + dst_rect->y = ee->req.h - src_rect->y - src_rect->height; + dst_rect->width = src_rect->width; + dst_rect->height = src_rect->height; + } + else if (ee->rotation == 270) + { + dst_rect->x = ee->req.w - src_rect->y - src_rect->height; + dst_rect->y = src_rect->x; + dst_rect->width = src_rect->height; + dst_rect->height = src_rect->width; + } + else + { + return 0; + } + + return 1; +#else + return 0; +#endif +} + +EAPI void +ecore_evas_x11_shape_input_rectangle_set(Ecore_Evas *ee, int x, int y, int w, int h) +{ +#ifdef BUILD_ECORE_EVAS_X11 + Eina_Bool ret; + Ecore_X_Rectangle src_rect; + Ecore_X_Rectangle dst_rect; + + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_x11_shape_input_rectangle_set"); + return; + } + + src_rect.x = x; + src_rect.y = y; + src_rect.width = w; + src_rect.height = h; + + ret = _ecore_evas_x11_convert_rectangle_with_angle(ee, &dst_rect, &src_rect); + + if (!ee->engine.x.win_shaped_input) + ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1); + + if (ret) + ecore_x_window_shape_input_rectangle_set(ee->engine.x.win_shaped_input, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height); +#else + return; + ee = NULL; + x = 0; + y = 0; + w = 0; + h = 0; +#endif +} + +EAPI void +ecore_evas_x11_shape_input_rectangle_add(Ecore_Evas *ee, int x, int y, int w, int h) +{ +#ifdef BUILD_ECORE_EVAS_X11 + Eina_Bool ret; + Ecore_X_Rectangle src_rect; + Ecore_X_Rectangle dst_rect; + + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_x11_shape_input_rectangle_add"); + return; + } + + src_rect.x = x; + src_rect.y = y; + src_rect.width = w; + src_rect.height = h; + + ret = _ecore_evas_x11_convert_rectangle_with_angle(ee, &dst_rect, &src_rect); + + if (!ee->engine.x.win_shaped_input) + ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1); + + if (ret) + ecore_x_window_shape_input_rectangle_add(ee->engine.x.win_shaped_input, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height); +#else + return; + ee = NULL; + x = 0; + y = 0; + w = 0; + h = 0; +#endif +} + +EAPI void +ecore_evas_x11_shape_input_rectangle_subtract(Ecore_Evas *ee, int x, int y, int w, int h) +{ +#ifdef BUILD_ECORE_EVAS_X11 + Eina_Bool ret; + Ecore_X_Rectangle src_rect; + Ecore_X_Rectangle dst_rect; + + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_x11_shape_input_rectangle_subtract"); + return; + } + + src_rect.x = x; + src_rect.y = y; + src_rect.width = w; + src_rect.height = h; + + ret = _ecore_evas_x11_convert_rectangle_with_angle(ee, &dst_rect, &src_rect); + + if (!ee->engine.x.win_shaped_input) + ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1); + + if (ret) + ecore_x_window_shape_input_rectangle_subtract(ee->engine.x.win_shaped_input, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height); +#else + return; + ee = NULL; + x = 0; + y = 0; + w = 0; + h = 0; +#endif +} + +EAPI void +ecore_evas_x11_shape_input_empty(Ecore_Evas *ee) +{ +#ifdef BUILD_ECORE_EVAS_X11 + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_x11_shape_input_empty"); + return; + } + + if (!ee->engine.x.win_shaped_input) + ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1); + + ecore_x_window_shape_input_rectangle_set(ee->engine.x.win_shaped_input, 0, 0, 0, 0); +#else + return; + ee = NULL; +#endif +} + +EAPI void +ecore_evas_x11_shape_input_reset(Ecore_Evas *ee) +{ +#ifdef BUILD_ECORE_EVAS_X11 + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_x11_shape_input_reset"); + return; + } + + if (!ee->engine.x.win_shaped_input) + ee->engine.x.win_shaped_input = ecore_x_window_override_new(ee->engine.x.win_root, 0, 0, 1, 1); + + ecore_x_window_shape_input_rectangle_set(ee->engine.x.win_shaped_input, 0, 0, 65535, 65535); +#else + return; + ee = NULL; +#endif +} + +EAPI void +ecore_evas_x11_shape_input_apply(Ecore_Evas *ee) +{ +#ifdef BUILD_ECORE_EVAS_X11 + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_x11_shape_input_apply"); + return; + } + + if (!ee->engine.x.win_shaped_input) return; + + ecore_x_window_shape_input_window_set(ee->prop.window, ee->engine.x.win_shaped_input); +#else + return; + ee = NULL; +#endif +} + diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h index 6355d9a..677a2af 100644 --- a/src/lib/ecore_x/Ecore_X.h +++ b/src/lib/ecore_x/Ecore_X.h @@ -1505,6 +1505,11 @@ EAPI void ecore_x_window_shape_window_set_xy( Ecore_X_Window shape_win, int x, int y); +EAPI void ecore_x_window_shape_window_set_xy( + Ecore_X_Window win, + Ecore_X_Window shape_win, + int x, + int y); EAPI void ecore_x_window_shape_rectangle_set( Ecore_X_Window win, int x, @@ -1515,6 +1520,42 @@ EAPI void ecore_x_window_shape_rectangles_set( Ecore_X_Window win, Ecore_X_Rectangle *rects, int num); +EAPI void ecore_x_window_shape_input_rectangle_set( + Ecore_X_Window win, + int x, + int y, + int w, + int h); +EAPI void ecore_x_window_shape_input_rectangles_set( + Ecore_X_Window win, + Ecore_X_Rectangle *rects, + int num); +EAPI void ecore_x_window_shape_input_rectangle_add( + Ecore_X_Window win, + int x, + int y, + int w, + int h); +EAPI void ecore_x_window_shape_rectangle_subtract( + Ecore_X_Window win, + int x, + int y, + int w, + int h); +EAPI void ecore_x_window_shape_input_rectangle_subtract( + Ecore_X_Window win, + int x, + int y, + int w, + int h); +EAPI void ecore_x_window_shape_input_window_set_xy( + Ecore_X_Window win, + Ecore_X_Window shape_win, + int x, + int y); +EAPI void ecore_x_window_shape_input_window_set( + Ecore_X_Window win, + Ecore_X_Window shape_win); EAPI void ecore_x_window_shape_window_add( Ecore_X_Window win, Ecore_X_Window shape_win); @@ -1523,6 +1564,11 @@ EAPI void ecore_x_window_shape_window_add_xy( Ecore_X_Window shape_win, int x, int y); +EAPI void ecore_x_window_shape_input_window_add_xy( + Ecore_X_Window win, + Ecore_X_Window shape_win, + int x, + int y); EAPI void ecore_x_window_shape_rectangle_add( Ecore_X_Window win, int x, @@ -1535,16 +1581,29 @@ EAPI void ecore_x_window_shape_rectangle_clip( int y, int w, int h); +EAPI void ecore_x_window_shape_input_rectangle_clip( + Ecore_X_Window win, + int x, + int y, + int w, + int h); EAPI void ecore_x_window_shape_rectangles_add( Ecore_X_Window win, Ecore_X_Rectangle *rects, int num); +EAPI void ecore_x_window_shape_input_rectangles_add( + Ecore_X_Window win, + Ecore_X_Rectangle *rects, + int num); EAPI void ecore_x_window_shape_rectangles_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_window_shape_rectangles_get_fetch(void); EAPI Ecore_X_Rectangle * ecore_x_window_shape_rectangles_get( Ecore_X_Window win, int *num_ret); +EAPI Ecore_X_Rectangle * ecore_x_window_shape_input_rectangles_get( + Ecore_X_Window win, + int *num_ret); EAPI void ecore_x_window_shape_events_select( Ecore_X_Window win, Eina_Bool on); diff --git a/src/lib/ecore_x/xlib/ecore_x_composite.c b/src/lib/ecore_x/xlib/ecore_x_composite.c index 5205d5c..309ee3f 100644 --- a/src/lib/ecore_x/xlib/ecore_x_composite.c +++ b/src/lib/ecore_x/xlib/ecore_x_composite.c @@ -131,12 +131,10 @@ EAPI Ecore_X_Pixmap ecore_x_composite_name_window_pixmap_get(Ecore_X_Window win) { Ecore_X_Pixmap pixmap = None; - #ifdef ECORE_XCOMPOSITE LOGFN(__FILE__, __LINE__, __FUNCTION__); pixmap = XCompositeNameWindowPixmap(_ecore_x_disp, win); #endif /* ifdef ECORE_XCOMPOSITE */ - return pixmap; } /* ecore_x_composite_name_window_pixmap_get */ @@ -144,13 +142,7 @@ EAPI void ecore_x_composite_window_events_disable(Ecore_X_Window win) { #ifdef ECORE_XCOMPOSITE - XRectangle rect; - rect.x = -1; - rect.y = -1; - rect.width = 1; - rect.height = 1; - XShapeCombineRectangles(_ecore_x_disp, win, ShapeInput, 0, 0, &rect, 1, - ShapeSet, Unsorted); + ecore_x_window_shape_input_rectangle_set(win, -1, -1, 1, 1); #endif /* ifdef ECORE_XCOMPOSITE */ } @@ -158,13 +150,7 @@ EAPI void ecore_x_composite_window_events_enable(Ecore_X_Window win) { #ifdef ECORE_XCOMPOSITE - XRectangle rect; - rect.x = 0; - rect.y = 0; - rect.width = 65535; - rect.height = 65535; - XShapeCombineRectangles(_ecore_x_disp, win, ShapeInput, 0, 0, &rect, 1, - ShapeSet, Unsorted); + ecore_x_window_shape_input_rectangle_set(win, 0, 0, 65535, 65535); #endif /* ifdef ECORE_XCOMPOSITE */ } @@ -173,16 +159,8 @@ ecore_x_composite_render_window_enable(Ecore_X_Window root) { Ecore_X_Window win = 0; #ifdef ECORE_XCOMPOSITE - XRectangle rect; - - LOGFN(__FILE__, __LINE__, __FUNCTION__); win = XCompositeGetOverlayWindow(_ecore_x_disp, root); - rect.x = -1; - rect.y = -1; - rect.width = 1; - rect.height = 1; - XShapeCombineRectangles(_ecore_x_disp, win, ShapeInput, 0, 0, &rect, 1, - ShapeSet, Unsorted); + ecore_x_composite_window_events_disable(win); #endif /* ifdef ECORE_XCOMPOSITE */ return win; } /* ecore_x_composite_render_window_enable */ diff --git a/src/lib/ecore_x/xlib/ecore_x_window_shape.c b/src/lib/ecore_x/xlib/ecore_x_window_shape.c index f0362d3..7ffc39f 100644 --- a/src/lib/ecore_x/xlib/ecore_x_window_shape.c +++ b/src/lib/ecore_x/xlib/ecore_x_window_shape.c @@ -29,6 +29,25 @@ ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask) XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet); } /* ecore_x_window_shape_mask_set */ +/** + * Sets the input shape of the given window to that given by the pixmap @p mask. + * @param win The given window. + * @param mask A 1-bit depth pixmap that provides the new input shape of the + * window. + * @ingroup Ecore_X_Window_Shape + */ +EAPI void +ecore_x_window_shape_input_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask) +{ + LOGFN(__FILE__, __LINE__, __FUNCTION__); +#ifdef ShapeInput + XShapeCombineMask(_ecore_x_disp, win, ShapeInput, 0, 0, mask, ShapeSet); +#else /* ifdef ShapeInput */ + return; + win = mask = 0; +#endif /* ifdef ShapeInput */ +} /* ecore_x_window_shape_input_mask_set */ + EAPI void ecore_x_window_shape_window_set(Ecore_X_Window win, Ecore_X_Window shape_win) { @@ -44,6 +63,26 @@ ecore_x_window_shape_window_set(Ecore_X_Window win, Ecore_X_Window shape_win) } /* ecore_x_window_shape_window_set */ EAPI void +ecore_x_window_shape_input_window_set(Ecore_X_Window win, + Ecore_X_Window shape_win) +{ +#ifdef ShapeInput + LOGFN(__FILE__, __LINE__, __FUNCTION__); + XShapeCombineShape(_ecore_x_disp, + win, + ShapeInput, + 0, + 0, + shape_win, + ShapeInput, + ShapeSet); +#else + return; + win = shape_win = 0; +#endif +} /* ecore_x_window_shape_input_window_set */ + +EAPI void ecore_x_window_shape_window_set_xy(Ecore_X_Window win, Ecore_X_Window shape_win, int x, @@ -61,6 +100,28 @@ ecore_x_window_shape_window_set_xy(Ecore_X_Window win, } /* ecore_x_window_shape_window_set_xy */ EAPI void +ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win, + Ecore_X_Window shape_win, + int x, + int y) +{ +#ifdef ShapeInput + LOGFN(__FILE__, __LINE__, __FUNCTION__); + XShapeCombineShape(_ecore_x_disp, + win, + ShapeInput, + x, + y, + shape_win, + ShapeInput, + ShapeSet); +#else + return; + win = shape_win = x = y = 0; +#endif +} /* ecore_x_window_shape_input_window_set_xy */ + +EAPI void ecore_x_window_shape_rectangle_set(Ecore_X_Window win, int x, int y, @@ -86,29 +147,58 @@ ecore_x_window_shape_rectangle_set(Ecore_X_Window win, } /* ecore_x_window_shape_rectangle_set */ EAPI void +ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win, + int x, + int y, + int w, + int h) +{ +#ifdef ShapeInput + XRectangle rect; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeInput, + 0, + 0, + &rect, + 1, + ShapeSet, + Unsorted); +#else + return; + win = x = y = w = h = 0; +#endif +} /* ecore_x_window_shape_input_rectangle_set */ + +EAPI void ecore_x_window_shape_rectangles_set(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) { +#ifdef ShapeInput XRectangle *rect = NULL; int i; LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (!rects) return; if (num > 0) { rect = malloc(sizeof(XRectangle) * num); - if (rect) - for (i = 0; i < num; i++) - { - rect[i].x = rects[i].x; - rect[i].y = rects[i].y; - rect[i].width = rects[i].width; - rect[i].height = rects[i].height; - } - else - num = 0; + if (!rect) return; + for (i = 0; i < num; i++) + { + rect[i].x = rects[i].x; + rect[i].y = rects[i].y; + rect[i].width = rects[i].width; + rect[i].height = rects[i].height; + } } - XShapeCombineRectangles(_ecore_x_disp, win, ShapeBounding, @@ -118,11 +208,108 @@ ecore_x_window_shape_rectangles_set(Ecore_X_Window win, num, ShapeSet, Unsorted); - if (rect) - free(rect); + if (rect) free(rect); +#else + return; + win = rects = num = 0; +#endif } /* ecore_x_window_shape_rectangles_set */ EAPI void +ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win, + Ecore_X_Rectangle *rects, + int num) +{ +#ifdef ShapeInput + XRectangle *rect = NULL; + int i; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (!rects) return; + if (num > 0) + { + rect = malloc(sizeof(XRectangle) * num); + if (!rect) return; + for (i = 0; i < num; i++) + { + rect[i].x = rects[i].x; + rect[i].y = rects[i].y; + rect[i].width = rects[i].width; + rect[i].height = rects[i].height; + } + } + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeInput, + 0, + 0, + rect, + num, + ShapeSet, + Unsorted); + if (rect) free(rect); +#else + return; + win = rects = num = 0; +#endif +} /* ecore_x_window_shape_input_rectangles_set */ + +EAPI void +ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win, + int x, + int y, + int w, + int h) +{ + XRectangle rect; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeBounding, + 0, + 0, + &rect, + 1, + ShapeSubtract, + Unsorted); +} /* ecore_x_window_shape_rectangle_subtract */ + +EAPI void +ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win, + int x, + int y, + int w, + int h) +{ +#ifdef ShapeInput + XRectangle rect; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeInput, + 0, + 0, + &rect, + 1, + ShapeSubtract, + Unsorted); +#else + return; + win = x = y = w = h = 0; +#endif +} /* ecore_x_window_shape_input_rectangle_subtract */ + +EAPI void ecore_x_window_shape_window_add(Ecore_X_Window win, Ecore_X_Window shape_win) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -154,6 +341,28 @@ ecore_x_window_shape_window_add_xy(Ecore_X_Window win, } /* ecore_x_window_shape_window_add_xy */ EAPI void +ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win, + Ecore_X_Window shape_win, + int x, + int y) +{ +#ifdef ShapeInput + LOGFN(__FILE__, __LINE__, __FUNCTION__); + XShapeCombineShape(_ecore_x_disp, + win, + ShapeInput, + x, + y, + shape_win, + ShapeInput, + ShapeUnion); +#else + return; + win = shape_win = x = y = 0; +#endif +} /* ecore_x_window_shape_input_window_add_xy */ + +EAPI void ecore_x_window_shape_rectangle_add(Ecore_X_Window win, int x, int y, @@ -179,6 +388,36 @@ ecore_x_window_shape_rectangle_add(Ecore_X_Window win, } /* ecore_x_window_shape_rectangle_add */ EAPI void +ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win, + int x, + int y, + int w, + int h) +{ +#ifdef ShapeInput + XRectangle rect; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeInput, + 0, + 0, + &rect, + 1, + ShapeUnion, + Unsorted); +#else + return; + win = x = y = w = h = 0; +#endif +} /* ecore_x_window_shape_input_rectangle_add */ + +EAPI void ecore_x_window_shape_rectangle_clip(Ecore_X_Window win, int x, int y, @@ -204,6 +443,36 @@ ecore_x_window_shape_rectangle_clip(Ecore_X_Window win, } /* ecore_x_window_shape_rectangle_clip */ EAPI void +ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win, + int x, + int y, + int w, + int h) +{ +#ifdef ShapeInput + XRectangle rect; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeInput, + 0, + 0, + &rect, + 1, + ShapeIntersect, + Unsorted); +#else + return; + win = x = y = w = h = 0; +#endif +} /* ecore_x_window_shape_input_rectangle_clip */ + +EAPI void ecore_x_window_shape_rectangles_add(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) @@ -215,18 +484,16 @@ ecore_x_window_shape_rectangles_add(Ecore_X_Window win, if (num > 0) { rect = malloc(sizeof(XRectangle) * num); - if (rect) - for (i = 0; i < num; i++) - { - rect[i].x = rects[i].x; - rect[i].y = rects[i].y; - rect[i].width = rects[i].width; - rect[i].height = rects[i].height; - } - else - num = 0; + if (!rect) return; + for (i = 0; i < num; i++) + { + rect[i].x = rects[i].x; + rect[i].y = rects[i].y; + rect[i].width = rects[i].width; + rect[i].height = rects[i].height; + } } - + XShapeCombineRectangles(_ecore_x_disp, win, ShapeBounding, @@ -236,10 +503,48 @@ ecore_x_window_shape_rectangles_add(Ecore_X_Window win, num, ShapeUnion, Unsorted); - if (rect) - free(rect); + if (rect) free(rect); } /* ecore_x_window_shape_rectangles_add */ +EAPI void +ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win, + Ecore_X_Rectangle *rects, + int num) +{ +#ifdef ShapeInput + XRectangle *rect = NULL; + int i; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (num > 0) + { + rect = malloc(sizeof(XRectangle) * num); + if (!rect) return; + for (i = 0; i < num; i++) + { + rect[i].x = rects[i].x; + rect[i].y = rects[i].y; + rect[i].width = rects[i].width; + rect[i].height = rects[i].height; + } + } + + XShapeCombineRectangles(_ecore_x_disp, + win, + ShapeBounding, + 0, + 0, + rect, + num, + ShapeUnion, + Unsorted); + if (rect) free(rect); +#else + return; + win = rects = num = 0; +#endif +} /* ecore_x_window_shape_input_rectangles_add */ + EAPI Ecore_X_Rectangle * ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret) { @@ -251,24 +556,74 @@ ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret) rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeBounding, &num, &ord); if (rect) { + if (num < 1) + { + XFree(rect); + if (num_ret) *num_ret = 0; + return NULL; + } rects = malloc(sizeof(Ecore_X_Rectangle) * num); - if (rects) - for (i = 0; i < num; i++) - { - rects[i].x = rect[i].x; - rects[i].y = rect[i].y; - rects[i].width = rect[i].width; - rects[i].height = rect[i].height; - } - + if (!rects) + { + XFree(rect); + if (num_ret) *num_ret = 0; + return NULL; + } + for (i = 0; i < num; i++) + { + rects[i].x = rect[i].x; + rects[i].y = rect[i].y; + rects[i].width = rect[i].width; + rects[i].height = rect[i].height; + } XFree(rect); } + if (num_ret) *num_ret = num; + return rects; +} /* ecore_x_window_shape_rectangles_get */ - if (num_ret) - *num_ret = num; +EAPI Ecore_X_Rectangle * +ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret) +{ +#ifdef ShapeInput + XRectangle *rect; + Ecore_X_Rectangle *rects = NULL; + int i, num = 0, ord; + LOGFN(__FILE__, __LINE__, __FUNCTION__); + rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeInput, &num, &ord); + if (rect) + { + if (num < 1) + { + XFree(rect); + if (num_ret) *num_ret = 0; + return NULL; + } + rects = malloc(sizeof(Ecore_X_Rectangle) * num); + if (!rects) + { + XFree(rect); + if (num_ret) *num_ret = 0; + return NULL; + } + for (i = 0; i < num; i++) + { + rects[i].x = rect[i].x; + rects[i].y = rect[i].y; + rects[i].width = rect[i].width; + rects[i].height = rect[i].height; + } + XFree(rect); + } + if (num_ret) *num_ret = num; return rects; -} /* ecore_x_window_shape_rectangles_get */ +#else + if (num_ret) *num_ret = 0; + return NULL; + win = 0; +#endif +} /* ecore_x_window_shape_input_rectangles_get */ EAPI void ecore_x_window_shape_events_select(Ecore_X_Window win, Eina_Bool on) @@ -279,22 +634,3 @@ ecore_x_window_shape_events_select(Ecore_X_Window win, Eina_Bool on) else XShapeSelectInput(_ecore_x_disp, win, 0); } /* ecore_x_window_shape_events_select */ - -/** - * Sets the input shape of the given window to that given by the pixmap @p mask. - * @param win The given window. - * @param mask A 2-bit depth pixmap that provides the new input shape of the - * window. - * @ingroup Ecore_X_Window_Shape - */ -EAPI void -ecore_x_window_shape_input_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask) -{ - LOGFN(__FILE__, __LINE__, __FUNCTION__); -#ifdef ShapeInput - XShapeCombineMask(_ecore_x_disp, win, ShapeInput, 0, 0, mask, ShapeSet); -#else /* ifdef ShapeInput */ - XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet); -#endif /* ifdef ShapeInput */ -} /* ecore_x_window_shape_input_mask_set */ - -- 2.7.4