ecore_wl : input rect set/add/subtract added 04/58504/3 accepted/tizen/mobile/20160217.011152 accepted/tizen/tv/20160217.011223 accepted/tizen/wearable/20160217.011254 submit/tizen/20160216.120030
authorJunghwan Choi <jhhh.choi@samsung.com>
Mon, 1 Feb 2016 13:34:02 +0000 (22:34 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 16 Feb 2016 11:38:50 +0000 (03:38 -0800)
Change-Id: I0c3a8c675f91873cbdd96b7f1e6cc3bd5d582c87
Signed-off-by: Junghwan Choi <jhhh.choi@samsung.com>
src/lib/ecore_evas/Ecore_Evas.h
src/lib/ecore_evas/ecore_evas.c
src/lib/ecore_evas/ecore_evas_wayland.h
src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl_private.h
src/lib/ecore_wayland/ecore_wl_window.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c

index ac99c6a..5d2b5f4 100644 (file)
@@ -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
index fcd5940..8f63a5c 100644 (file)
@@ -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)
 {
index 80e7b04..9267d79 100644 (file)
@@ -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
index 971bff0..5a4164b 100644 (file)
@@ -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.
index 5163911..ef4d60c 100644 (file)
@@ -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; */
index 0be0ea5..748f3d9 100644 (file)
@@ -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)
index ee44c07..437265f 100644 (file)
@@ -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 =