From fcbb6bfcb01698cce6941187dd1c4a345c52eafa Mon Sep 17 00:00:00 2001 From: Junghwan Choi Date: Mon, 1 Feb 2016 22:34:02 +0900 Subject: [PATCH] ecore_wl : input rect set/add/subtract added Change-Id: I0c3a8c675f91873cbdd96b7f1e6cc3bd5d582c87 Signed-off-by: Junghwan Choi --- src/lib/ecore_evas/Ecore_Evas.h | 30 +++++++++ src/lib/ecore_evas/ecore_evas.c | 75 ++++++++++++++++++++++ src/lib/ecore_evas/ecore_evas_wayland.h | 3 + src/lib/ecore_wayland/Ecore_Wayland.h | 35 ++++++++++ src/lib/ecore_wayland/ecore_wl_private.h | 1 + src/lib/ecore_wayland/ecore_wl_window.c | 67 ++++++++++++++++++- .../engines/wayland/ecore_evas_wayland_common.c | 33 ++++++++++ 7 files changed, 243 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h index ac99c6a..5d2b5f4 100644 --- a/src/lib/ecore_evas/Ecore_Evas.h +++ b/src/lib/ecore_evas/Ecore_Evas.h @@ -874,6 +874,36 @@ EAPI const char *ecore_evas_aux_hint_val_get(const Ecore_Evas *ee, int id); */ EAPI int ecore_evas_aux_hint_id_get(const Ecore_Evas *ee, const char *hint); /** + * @brief Set an input rect of surface. + * + * @param ee The Ecore_Evas + * @param input_rect The rect of input to be set + * @warning Support for this depends on the underlying windowing system. + * + * @since 1.16 + */ +EAPI void ecore_evas_input_rect_set(Ecore_Evas *ee, Eina_Rectangle *input_rect); +/** + * @brief Set an input rect of surface. + * + * @param ee The Ecore_Evas + * @param input_rect The rect of input to be added + * @warning Support for this depends on the underlying windowing system. + * + * @since 1.16 + */ +EAPI void ecore_evas_input_rect_add(Ecore_Evas *ee, Eina_Rectangle *input_rect); +/** + * @brief Set an input rect of surface. + * + * @param ee The Ecore_Evas + * @param input_rect The rect of input to be subtracted + * @warning Support for this depends on the underlying windowing system. + * + * @since 1.16 + */ +EAPI void ecore_evas_input_rect_subtract(Ecore_Evas *ee, Eina_Rectangle *input_rect); +/** * @brief Query if the ecore evas is obscured or unobscured. * * @param ee The Ecore_Evas diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index fcd5940..8f63a5c 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -2422,6 +2422,81 @@ ecore_evas_aux_hint_id_get(const Ecore_Evas *ee, const char *hint) return -1; } +EAPI void +ecore_evas_input_rect_set(Ecore_Evas *ee, Eina_Rectangle *input_rect) +{ + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_input_rect_set"); + return EINA_FALSE; + } + + if (!strncmp(ee->driver, "wayland", 7)) + { + Ecore_Evas_Interface_Wayland *iface; + iface = (Ecore_Evas_Interface_Wayland *)_ecore_evas_interface_get(ee, "wayland"); + EINA_SAFETY_ON_NULL_RETURN(iface); + + if (iface->input_rect_set) + iface->input_rect_set(ee, input_rect); + + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI void +ecore_evas_input_rect_add(Ecore_Evas *ee, Eina_Rectangle *input_rect) +{ + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_input_rect_add"); + return EINA_FALSE; + } + + if (!strncmp(ee->driver, "wayland", 7)) + { + Ecore_Evas_Interface_Wayland *iface; + iface = (Ecore_Evas_Interface_Wayland *)_ecore_evas_interface_get(ee, "wayland"); + EINA_SAFETY_ON_NULL_RETURN(iface); + + if (iface->input_rect_add) + iface->input_rect_add(ee, input_rect); + + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI void +ecore_evas_input_rect_subtract(Ecore_Evas *ee, Eina_Rectangle *input_rect) +{ + if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) + { + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_input_rect_subtract"); + return EINA_FALSE; + } + + if (!strncmp(ee->driver, "wayland", 7)) + { + Ecore_Evas_Interface_Wayland *iface; + iface = (Ecore_Evas_Interface_Wayland *)_ecore_evas_interface_get(ee, "wayland"); + EINA_SAFETY_ON_NULL_RETURN(iface); + + if (iface->input_rect_subtract) + iface->input_rect_subtract(ee, input_rect); + + return EINA_TRUE; + } + + return EINA_FALSE; +} + EAPI Eina_Bool ecore_evas_obscured_get(const Ecore_Evas *ee) { diff --git a/src/lib/ecore_evas/ecore_evas_wayland.h b/src/lib/ecore_evas/ecore_evas_wayland.h index 80e7b04..9267d79 100644 --- a/src/lib/ecore_evas/ecore_evas_wayland.h +++ b/src/lib/ecore_evas/ecore_evas_wayland.h @@ -17,6 +17,9 @@ struct _Ecore_Evas_Interface_Wayland void (*aux_hint_change)(Ecore_Evas *ee, int id, const char *val); void (*aux_hint_del)(Ecore_Evas *ee, int id); void (*supported_aux_hints_get)(Ecore_Evas *ee); + void (*input_rect_set)(Ecore_Evas *ee, Eina_Rectangle *input_rect); + void (*input_rect_add)(Ecore_Evas *ee, Eina_Rectangle *input_rect); + void (*input_rect_subtract)(Ecore_Evas *ee, Eina_Rectangle *input_rect); }; #endif diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h index 971bff0..5a4164b 100644 --- a/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/src/lib/ecore_wayland/Ecore_Wayland.h @@ -796,6 +796,41 @@ EAPI Eina_Bool ecore_wl_window_alpha_get(Ecore_Wl_Window *win); EAPI Ecore_Wl_Window *ecore_wl_window_surface_find(struct wl_surface *surface); /** + * Set the input rect of the Ecore_Wl_Window. + * + * To set an empty rect, pass x and y and width and height as -1, -1, 1, 1. + * + * @param win The window + * @param input_rect The rectangle to be set as input + * + * @ingroup Ecore_Wl_Window_Group + * @since 1.8 + */ +EAPI void ecore_wl_window_input_rect_set(Ecore_Wl_Window *win, Eina_Rectangle *input_rect); + +/** + * Add the input rect of the Ecore_Wl_Window. + * + * @param win The window + * @param input_rect The rectangle to be added as input + * + * @ingroup Ecore_Wl_Window_Group + * @since 1.8 + */ +EAPI void ecore_wl_window_input_rect_add(Ecore_Wl_Window *win, Eina_Rectangle *input_rect); + +/** + * Subtract the input rect of the Ecore_Wl_Window. + * + * @param win The window + * @param input_rect The rectangle to be subtracted as input + * + * @ingroup Ecore_Wl_Window_Group + * @since 1.8 + */ +EAPI void ecore_wl_window_input_rect_subtract(Ecore_Wl_Window *win, Eina_Rectangle *input_rect); + +/** * Set the input region of the Ecore_Wl_Window. * * To set an empty region, pass width and height as 0. diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h index 5163911..ef4d60c 100644 --- a/src/lib/ecore_wayland/ecore_wl_private.h +++ b/src/lib/ecore_wayland/ecore_wl_private.h @@ -214,6 +214,7 @@ struct _Ecore_Wl_Window } rotation_geometry_hints[4]; Eina_List *supported_aux_hints; + struct wl_region *input_region; /* Eina_Bool redraw_scheduled : 1; */ /* Eina_Bool resize_scheduled : 1; */ diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c index 0be0ea5..748f3d9 100644 --- a/src/lib/ecore_wayland/ecore_wl_window.c +++ b/src/lib/ecore_wayland/ecore_wl_window.c @@ -431,7 +431,8 @@ ecore_wl_window_free(Ecore_Wl_Window *win) if (win->role) eina_stringshare_del(win->role); _ecore_wl_window_aux_hint_free(win); - + if (win->input_region) wl_region_destroy(win->input_region); + win->input_region = NULL; /* HMMM, why was this disabled ? */ free(win); } @@ -1063,6 +1064,70 @@ ecore_wl_window_surface_find(struct wl_surface *surface) return win; } +EAPI void +ecore_wl_window_input_rect_set(Ecore_Wl_Window *win, Eina_Rectangle *input_rect) +{ + Eina_Bool unset = EINA_FALSE; + if (!win) return; + if (!input_rect) return; + if (win->input_region) + wl_region_destroy(win->input_region); + + win->input.x = input_rect->x; + win->input.y = input_rect->y; + win->input.w = input_rect->w; + win->input.h = input_rect->h; + + if (win->type != ECORE_WL_WINDOW_TYPE_DND) + { + struct wl_region *region; + region = wl_compositor_create_region(_ecore_wl_compositor_get()); + if (!region) return; + + wl_region_add(region, input_rect->x, input_rect->y, input_rect->w, input_rect->h); + wl_surface_set_input_region(win->surface, region); + wl_region_destroy(region); + } +} + +EAPI void +ecore_wl_window_input_rect_add(Ecore_Wl_Window *win, Eina_Rectangle *input_rect) +{ + if (!win) return; + if (!input_rect) return; + if (input_rect->x < 0 || input_rect->y < 0) return; + + if (win->type != ECORE_WL_WINDOW_TYPE_DND) + { + if (!win->input_region) + { + struct wl_region *region; + region = wl_compositor_create_region(_ecore_wl_compositor_get()); + if (!region) return; + + win->input_region = region; + } + + wl_region_add(win->input_region, input_rect->x, input_rect->y, input_rect->w, input_rect->h); + wl_surface_set_input_region(win->surface, win->input_region); + } +} + +EAPI void +ecore_wl_window_input_rect_subtract(Ecore_Wl_Window *win, Eina_Rectangle *input_rect) +{ + if (!win) return; + if (!input_rect) return; + if (input_rect->x < 0 || input_rect->y < 0) return; + if (!win->input_region) return; + + if (win->type != ECORE_WL_WINDOW_TYPE_DND) + { + wl_region_subtract(win->input_region, input_rect->x, input_rect->y, input_rect->w, input_rect->h); + wl_surface_set_input_region(win->surface, win->input_region); + } +} + /* @since 1.8 */ EAPI void ecore_wl_window_input_region_set(Ecore_Wl_Window *win, int x, int y, int w, int h) diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c index ee44c07..437265f 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c @@ -1873,6 +1873,36 @@ _ecore_evas_wayland_pointer_set(Ecore_Evas *ee EINA_UNUSED, int hot_x EINA_UNUSE } static void +_ecore_evas_wayland_input_rect_set(Ecore_Evas *ee, Eina_Rectangle *input_rect) +{ + Ecore_Evas_Engine_Wl_Data *wdata; + + if (!ee) return; + wdata = ee->engine.data; + ecore_wl_window_input_rect_set(wdata->win, input_rect); +} + +static void +_ecore_evas_wayland_input_rect_add(Ecore_Evas *ee, Eina_Rectangle *input_rect) +{ + Ecore_Evas_Engine_Wl_Data *wdata; + + if (!ee) return; + wdata = ee->engine.data; + ecore_wl_window_input_rect_add(wdata->win, input_rect); +} + +static void +_ecore_evas_wayland_input_rect_subtract(Ecore_Evas *ee, Eina_Rectangle *input_rect) +{ + Ecore_Evas_Engine_Wl_Data *wdata; + + if (!ee) return; + wdata = ee->engine.data; + ecore_wl_window_input_rect_subtract(wdata->win, input_rect); +} + +static void _ecore_evas_wayland_supported_aux_hints_get(Ecore_Evas *ee) { Ecore_Evas_Engine_Wl_Data *wdata; @@ -1932,6 +1962,9 @@ _ecore_evas_wl_interface_new(void) iface->aux_hint_change = _ecore_evas_wayland_aux_hint_change; iface->aux_hint_del = _ecore_evas_wayland_aux_hint_del; iface->supported_aux_hints_get = _ecore_evas_wayland_supported_aux_hints_get; + iface->input_rect_set = _ecore_evas_wayland_input_rect_set; + iface->input_rect_add = _ecore_evas_wayland_input_rect_add; + iface->input_rect_subtract = _ecore_evas_wayland_input_rect_subtract; #ifdef BUILD_ECORE_EVAS_WAYLAND_EGL iface->pre_post_swap_callback_set = -- 2.7.4