Add e_client_under_position_input_get() 27/283327/1 tizen_6.5
authorArtur Świgoń <a.swigon@samsung.com>
Thu, 20 Oct 2022 09:19:59 +0000 (11:19 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Mon, 24 Oct 2022 09:03:42 +0000 (11:03 +0200)
Similarly to e_client_under_position_get(), it performs a hit-test, but input
regions are also considered. If input regions are present, then the specified
position needs to be inside such a region.

Change-Id: Ie75c346ffc6e535fdb678e7b5748435f9a003bbb

src/bin/e_client.c
src/bin/e_client.h

index 37b11ff4606ce1f475bf5a224de55c9cc846930f..32594d5651da6ed97559c789632ec747695132b7 100644 (file)
@@ -1985,6 +1985,18 @@ _e_client_resize_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *
 
 ////////////////////////////////////////////////
 
+static Eina_Bool
+_e_client_under_pointer_helper_ignore_client(E_Desk *desk, E_Client *ec)
+{
+   /* If a border was specified which should be excluded from the list
+    * (because it will be closed shortly for example), skip */
+   if (e_client_util_ignored_get(ec) || (!e_client_util_desk_visible(ec, desk))) return EINA_TRUE;
+   if (!evas_object_visible_get(ec->frame)) return EINA_TRUE;
+   if (e_policy_client_is_cursor(ec)) return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
 static E_Client *
 _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y)
 {
@@ -1992,11 +2004,7 @@ _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y)
 
    E_CLIENT_REVERSE_FOREACH(cec)
      {
-        /* If a border was specified which should be excluded from the list
-         * (because it will be closed shortly for example), skip */
-        if (e_client_util_ignored_get(cec) || (!e_client_util_desk_visible(cec, desk))) continue;
-        if (!evas_object_visible_get(cec->frame)) continue;
-        if (e_policy_client_is_cursor(cec)) continue;
+        if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue;
         if ((exclude) && (cec == exclude)) continue;
         if (!E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h))
           continue;
@@ -2008,6 +2016,43 @@ _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y)
    return ec;
 }
 
+static E_Client *
+_e_client_under_pointer_input_helper(E_Desk *desk, int x, int y)
+{
+   E_Client *ec = NULL, *cec;
+
+   E_CLIENT_REVERSE_FOREACH(cec)
+     {
+        if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue;
+
+        Eina_List *list = NULL;
+        Eina_Rectangle *rect;
+        Eina_Bool inside = EINA_FALSE;
+        e_comp_object_input_rect_get(cec->frame, &list);
+        if (list)
+          {
+             EINA_LIST_FREE(list, rect)
+               {
+                  if (E_INSIDE(x, y, rect->x, rect->y, rect->w, rect->h))
+                    inside = EINA_TRUE;
+               }
+          }
+        else
+          {
+             if (E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h))
+               inside = EINA_TRUE;
+          }
+
+        if (!inside) continue;
+        /* If the layer is higher, the position of the window is higher
+         * (always on top vs always below) */
+        if (!ec || (cec->layer > ec->layer))
+          ec = cec;
+     }
+
+   return ec;
+}
+
 ////////////////////////////////////////////////
 
 static void
@@ -7079,6 +7124,13 @@ E_API E_Client *e_client_under_position_get(E_Desk *desk, int x, int y, E_Client
    return _e_client_under_pointer_helper(desk, exclude, x, y);
 }
 
+E_API E_Client *e_client_under_position_input_get(E_Desk *desk, int x, int y)
+{
+   if (!desk) return NULL;
+
+   return _e_client_under_pointer_input_helper(desk, x, y);
+}
+
 ////////////////////////////////////////////
 
 E_API int
index ddf8a86cf09e676cd0f04ba57c6741ad62a40f2f..ee08484f719d0bab4c81282420a5bc20b080a053 100644 (file)
@@ -1171,6 +1171,7 @@ E_API void e_client_signal_resize_end(E_Client *ec, const char *dir EINA_UNUSED,
 E_API void e_client_resize_limit(E_Client *ec, int *w, int *h);
 E_API E_Client *e_client_under_pointer_get(E_Desk *desk, E_Client *exclude);
 E_API E_Client *e_client_under_position_get(E_Desk *desk, int x, int y, E_Client *exclude);
+E_API E_Client *e_client_under_position_input_get(E_Desk *desk, int x, int y);
 E_API int e_client_pointer_warp_to_center_now(E_Client *ec);
 E_API int e_client_pointer_warp_to_center(E_Client *ec);
 E_API void e_client_redirected_set(E_Client *ec, Eina_Bool set);